Bug 740003

Summary: Message properties discrepancies using java client
Product: Red Hat Enterprise MRG Reporter: Petr Matousek <pematous>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED NOTABUG QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: low Docs Contact:
Priority: medium    
Version: DevelopmentCC: iboverma, jneedle, jross
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-16 09:22:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Matousek 2011-09-20 16:35:07 UTC
Description of problem:

I have noticed following distinction in the properties of messages sent by java
client (IMHO: it is highly probable that some of the issues have the same cause, the issues are probably more 'message display issues' than real bugs in message properties):

1.) The priority is always set to 4 by default (if not specified). There shall be no priority, until specified by client. (this is probably the priority set on SENDER object, but other clients do not reflect it)

2.) delivery_mode is always set to 2 by default (if not specified). This means that the message is durable by default.

3.) user_id is always set to 'guest' by default. There shall be no user_id set, until specified by client.

4.) The id of the message is held in JMSMessageID. Other clients (c++, python) holds the message id as a part of the properties (nested map). If it is necessary to hold the id in JMSMessageID, the copy of the id shall be also held in the nested map of properties.

5.) It is unable to read properties set by c++ client - this is probably c++ issue, please see Bug 739979 (point 3)

6.) The priority and delivery mode is incorrectly displayed when reading messages sent by other clients. The priority 4 is always displayed and delivery mode 2 is always displayed even if the message priority and delivery mode is not set.

7.) Nested map of properties always contains property 'content-encoding'. This is not necessarily wrong, but other clients do not set the 'content-encoding' by default (maybe bug of other clients, that they do not set the encoding?)

8.) Incorrect content-type is displayed by default (application/octet-stream), if the message does not have content-type adjusted.

All the clients shall behave the same way.

Version-Release number of selected component (if applicable):
qpid-java-0.10-9

How reproducible:
100%

Steps to Reproduce:
Please see additional info for details.
  
Actual results:
priority is set to 4 by default
delivery_mode is set to 2 by default
user_id is set to 'guest' by default
content-type is set 'application/octet-stream' by default 
missing property 'spout-id' in the nested map of properties
message properties set by c++ client can not be read
incorrect priority and delivery_mode is displayed on messages sent by other clients
extra property 'content-encoding' is present in the nested map of properties

Expected results:
no value is set for priority by default
no value is set for delivery_mode by default
no value is set for user_id by default
no value is set for content-type by default
'spout-id' property is present in the nested map of properties
message properties set by c++ client can be correctly read
appropriate priority and delivery_mode is displayed on messages sent by other clients
'content-encoding' is not present in nested map of properties by default

Additional info:

The following code demostrates sending a message with c++, python and java client respectively and receiving these messages with the c++, python, java clients:

# qpid-config add queue q
# $cppapi/spout --content "message sent by c++ client" q
**************************
id         : 
subject    : 
user       : 
replyto    :  
correlation: 
durable    : 0
priority   : 
ttl        : 0
redeliver  : 0
props      : {spout-id:2f805cfc-c725-4502-905c-07fedda0fad2:0}
contentType: text/plain
content    : message sent by c++ client
**************************
# $pyapi/spout q "message sent by python client"
**************************
id         : None
subject    : None
user       : None
replyto    : None
correlation: None
durable    : None
priority   : None
ttl        : None
redeliver  : False
props      : {'spout-id': '4d372c5f-781f-0a45-b297-3bd6fc5239b1:0'}
contentType: None
content    : message sent by python client
**************************
Message(properties={'spout-id': '4d372c5f-781f-0a45-b297-3bd6fc5239b1:0'}, content='message sent by python client')
# java -cp $CLASSPATH org.apache.qpid.example.Spout --content "message sent by java client" q
{content=message sent by java client}

------------- Msg -------------
Body:
message sent by java client
JMS Correlation ID: null
JMS timestamp: 1316447759278
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: 'q'/None; None
JMS Type: null
JMS MessageID: ID:e855defa-f471-3f9d-b8f0-89ed7265ee05
JMS Content-Type: text/plain
AMQ message number: -1
Properties:<NONE>
-------------------------------

# $cppapi/drain -c 0 "q;{mode: browse}"
Message(properties={spout-id:2f805cfc-c725-4502-905c-07fedda0fad2:0, x-amqp-0-10.routing-key:q}, content='message sent by c++ client')
**************************
id         : 
subject    : 
user       : 
replyto    :  
correlation: 
durable    : 0
priority   : 
ttl        : 0
redeliver  : 0
props      : {spout-id:2f805cfc-c725-4502-905c-07fedda0fad2:0, x-amqp-0-10.routing-key:q}
contentType: text/plain
content    : message sent by c++ client
**************************
Message(properties={spout-id:4d372c5f-781f-0a45-b297-3bd6fc5239b1:0, x-amqp-0-10.routing-key:q}, content='message sent by python client')
**************************
id         : 
subject    : 
user       : 
replyto    :  
correlation: 
durable    : 0
priority   : 
ttl        : 0
redeliver  : 0
props      : {spout-id:4d372c5f-781f-0a45-b297-3bd6fc5239b1:0, x-amqp-0-10.routing-key:q}
contentType: 
content    : message sent by python client
**************************
Message(properties={x-amqp-0-10.content-encoding:UTF-8, x-amqp-0-10.routing-key:q}, content='message sent by java client')
**************************
id         : e855defa-f471-3f9d-b8f0-89ed7265ee05
subject    : 
user       : guest
replyto    :  
correlation: 
durable    : 1
priority   : 
ttl        : 0
redeliver  : 0
props      : {x-amqp-0-10.content-encoding:UTF-8, x-amqp-0-10.routing-key:q}
contentType: text/plain
content    : message sent by java client
**************************
# $pyapi/drain "q;{mode: browse}"
Message(user_id='', correlation_id='', properties={'x-amqp-0-10.routing-key': u'q', u'spout-id': '2f805cfc-c725-4502-905c-07fedda0fad2:0'}, content=u'message sent by c++ client')
**************************
id         : None
subject    : None
user       : 
replyto    : None
correlation: 
durable    : None
priority   : None
ttl        : None
redeliver  : False
props      : {'x-amqp-0-10.routing-key': u'q', u'spout-id': '2f805cfc-c725-4502-905c-07fedda0fad2:0'}
contentType: text/plain
content    : message sent by c++ client
**************************
Message(properties={'x-amqp-0-10.routing-key': u'q', u'spout-id': u'4d372c5f-781f-0a45-b297-3bd6fc5239b1:0'}, content='message sent by python client')
**************************
id         : None
subject    : None
user       : None
replyto    : None
correlation: None
durable    : None
priority   : None
ttl        : None
redeliver  : False
props      : {'x-amqp-0-10.routing-key': u'q', u'spout-id': u'4d372c5f-781f-0a45-b297-3bd6fc5239b1:0'}
contentType: None
content    : message sent by python client
**************************
Message(id=UUID('e855defa-f471-3f9d-b8f0-89ed7265ee05'), user_id='guest', priority=4, durable=True, properties={'x-amqp-0-10.content-encoding': u'UTF-8', 'x-amqp-0-10.routing-key': u'q'}, content=u'message sent by java client')
**************************
id         : e855defa-f471-3f9d-b8f0-89ed7265ee05
subject    : None
user       : guest
replyto    : None
correlation: None
durable    : True
priority   : 4
ttl        : None
redeliver  : False
props      : {'x-amqp-0-10.content-encoding': u'UTF-8', 'x-amqp-0-10.routing-key': u'q'}
contentType: text/plain
content    : message sent by java client
**************************
# java -cp $CLASSPATH org.apache.qpid.example.Drain "q;{mode:browse}"
{}

------------- Msg -------------
Body:
message sent by c++ client
JMS Correlation ID: 
JMS timestamp: 0
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: :///q/q?routingkey='q'
JMS Type: null
JMS MessageID: null
JMS Content-Type: text/plain
AMQ message number: 2
Properties:<NONE>
-------------------------------

------------- Msg -------------
Body:
"message sent by python client"
JMS Correlation ID: null
JMS timestamp: 0
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: :///q/q?routingkey='q'
JMS Type: null
JMS MessageID: null
JMS Content-Type: application/octet-stream
AMQ message number: 3
Properties:
	spout-id = 4d372c5f-781f-0a45-b297-3bd6fc5239b1:0

-------------------------------

------------- Msg -------------
Body:
message sent by java client
JMS Correlation ID: null
JMS timestamp: 1316447759278
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: :///q/q?routingkey='q'
JMS Type: null
JMS MessageID: ID:e855defa-f471-3f9d-b8f0-89ed7265ee05
JMS Content-Type: text/plain
AMQ message number: 4
Properties:<NONE>
-------------------------------

Comment 3 Rajith Attapattu 2012-02-14 22:13:47 UTC
1.) The message producer's default priority is 4

2.) The message producer's default delivery mode is PERSISTENT

3.) user_id is always set to 'guest' by default. The user_id is set to what ever the identity used. Since we use guest/guest as default, it gets set to guest.

4.) The id of the message is held in message-properties. When getJMSMessageID is called we retrieve it from message properties. When displaying a JMS Message we map the required fields to the JMS properties, as we don't display any AMQP specific props. After all this is a JMS client and it's fine to be different from the Qpid client.

5.) It's not really an issue with the C++ client. The application needs to set the correct encoding. Example for python you can do that by using u'my-string instead of my-string.

6.) If priority and delivery mode is not set explicitly by other clients then the jms client selects the defaults as specified by the spec. 

7.) Nested map of properties always contains property 'content-encoding'. This
is not necessarily wrong, but other clients do not set the 'content-encoding'
by default (maybe bug of other clients, that they do not set the encoding?)
See #5.

8.) Incorrect content-type is displayed by default (application/octet-stream),
if the message does not have content-type adjusted.

This is not incorrect. The default message type is BytesMessage and Qpid uses "application/octet-stream" to denote a bytes payload.

Hope this clarifies the questions.

Comment 4 Petr Matousek 2012-08-16 09:22:19 UTC
Rajith, thanks much for explanations. The target was to unify the form of the message across supported clients. At the time of filling this bz I wasn't aware of that java client message shall comply to JMS Message, moreover majority of the mentioned issues are issues with the client examples implementation rather than with the clients, closing as not a bug.

-> NOTABUG