You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Damon Rolfs <dr...@gmail.com> on 2011/02/04 00:46:48 UTC

Java Client connecting to C++ Broker Examples?

I'm trying to write a simple Java client (using qpid-java-client-0.8) to
demonstrate communicating with a C++ QPID broker (AMQP 0.10). I would
appreciate any example code demonstrating a Java qpid client connecting to a
C++ qpid broker. I've found several examples of Java JMS and native clients
connecting to Java brokers, but none for Java -> C++.

I've been working to adapt the pure Java examples, however I've run into
issues I've been unable to resolve. I've had best luck using the AMQ*
classes rather than the JMS classes. I've been able to connect to the broker
and send a message into the exchange. The message gets dropped however
because my routing key is not set, despite my code setting it by explicitly
calling the AMQDestination.setRoutingKey() method. When I print the
Destination, I get: JMS Destination: :////?routingkey=''.

Using another (C++) client, I place a message for the Java client in a
queue. I have not been able to receive that message using the Java client.

Thank you in advance for your guidance.

Damon

Here's a snippet from my client sample (I removed some of the log code that
shows up below):

AMQConnection connection = new AMQConnection( host, port, "root", "r00tpw",
"10.1.3.3", "/" );
Session session = connection.createSession( true, Session.AUTO_ACKNOWLEDGE
);
AMQAnyDestination outboundQ = new AMQAnyDestination(
"ADDR:"+sendToExchange+"; {create: always}" );
outboundQ.setRoutingKey( new AMQShortString(routingKey) ); // routing key is
a string: B.RRAA.AMQPApp2Key.Something

AMQAnyDestination inboundQ = new AMQAnyDestination(
"ADDR:"+receivingQueue+"; {create: always}" );

MessageProducer producer = session.createProducer( outboundQ );
MessageConsumer consumer = session.createConsumer( inboundQ );

BytesMessage outboundMessage = createEmpMessage( session, empDataString );
// creates and populates a JMS BytesMessage
producer.send( outboundMessage );

Message inboundMessage = consumer.receive( 10 * 1000 ); // I've also tried
setting up a listener to no avail
String msgType = (inboundMessage != null) ? inboundMessage.getJMSType :
"###NULL###";
Logger.info( "RECEIVED:type:"+msgType+"\tcontent:"+inboundMessage );
connection.close();

this is the log output:

983 [run-main] INFO itcm.JvmAmqpClient$ - identity:amqpapplication1
983 [run-main] INFO itcm.JvmAmqpClient$ - host:10.1.3.3
986 [run-main] INFO itcm.JvmAmqpClient$ - port:10002
986 [run-main] INFO itcm.JvmAmqpClient$ - count:1
986 [run-main] INFO itcm.JvmAmqpClient$ -
sendToExchange:FromExternalAMQPApp1.Ex
986 [run-main] INFO itcm.JvmAmqpClient$ -
routingKey:B.RRAA.AMQPApp2Key.Something
986 [run-main] INFO itcm.JvmAmqpClient$ - receivingQueue:ToAMQPApp1Queue
986 [run-main] INFO itcm.JvmAmqpClient$ - empDataString:Hello World!
986 [run-main] INFO itcm.JvmAmqpClient$ - Attempting to connection to:
amqp://root:********@10.1.3.3:10002/?brokerlist='tcp://10.1.3.3:10002<http://10.1.3.3:10002/?brokerlist=%27tcp://10.1.3.3:10002>
'
1334 [run-main] INFO org.apache.qpid.client.AMQConnection -
Connection:amqp://root:********@
10.1.3.3/?ssl='false'&brokerlist='tcp://10.1.3.3:10002'&ssl='false<http://10.1.3.3/?ssl=%27false%27&brokerlist=%27tcp://10.1.3.3:10002%27&ssl=%27false>
'
3382 [run-main] INFO org.apache.qpid.client.protocol.AMQProtocolSession -
Using ProtocolVersion for Session:0-10
3434 [run-main] INFO
org.apache.qpid.client.handler.ClientMethodDispatcherImpl - New Method
Dispatcher:AMQProtocolSession[null]
3491 [run-main] INFO org.apache.qpid.client.AMQConnection - Connecting with
ProtocolHandler Version:0-10
3944 [run-main] INFO org.apache.qpid.client.AMQConnection - Connected with
ProtocolHandler Version:0-10
3945 [run-main] INFO itcm.JvmAmqpClient$ - creating Session...
3981 [run-main] INFO org.apache.qpid.client.AMQSession - Created
session:org.apache.qpid.client.AMQSession_0_10@5ba0d9
3996 [run-main] INFO itcm.JvmAmqpClient$ - creating destination...
4101 [run-main] INFO itcm.JvmAmqpClient$ - outboundQ:
'FromExternalAMQPApp1.Ex'/None; {
  'create': 'always'
}
4101 [run-main] INFO itcm.JvmAmqpClient$ - outboundQ.routingKey:
B.RRAA.AMQPApp2Key.Something
4101 [run-main] INFO itcm.JvmAmqpClient$ - inboundQ: 'ToAMQPApp1Queue'/None;
{
  'create': 'always'
}
4101 [run-main] INFO itcm.JvmAmqpClient$ - connecting producer to
FromExternalAMQPApp1.Ex
4126 [run-main] INFO org.apache.qpid.client.BasicMessageProducer_0_10 -
MessageProducer
org.apache.qpid.client.BasicMessageProducer_0_10@165a5fausing publish
mode : ASYNC_PUBLISH_ALL
4126 [run-main] INFO itcm.JvmAmqpClient$ - connecting consumer to
ToAMQPApp1Queue
4159 [run-main] INFO org.apache.qpid.client.AMQSession - Prefetching delayed
existing messages will not flow until requested via receive*() or setML().
4206 [run-main] INFO itcm.JvmAmqpClient$ - crafting EMP message...
4224 [run-main] INFO itcm.JvmAmqpClient$ - bytemessage:Body:
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Hello
World!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"...
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: :////?routingkey=''
JMS Type: null
JMS MessageID: null
JMS Content-Type: application/octet-stream
AMQ message number: -1
Properties:<NONE>
4224 [run-main] INFO itcm.JvmAmqpClient$ - out msg destination:
:////?routingkey=''
4225 [run-main] INFO itcm.JvmAmqpClient$ - sending message:Body:
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Hello
World!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"...
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: :////?routingkey=''
JMS Type: null
JMS MessageID: null
JMS Content-Type: application/octet-stream
AMQ message number: -1
Properties:<NONE>
4229 [run-main] INFO itcm.JvmAmqpClient$ - receiving message...
4238 [run-main] INFO org.apache.qpid.client.AMQSession.Dispatcher -
Dispatcher-Channel-1 created
4239 [Dispatcher-Channel-1] INFO
org.apache.qpid.client.AMQSession.Dispatcher - Dispatcher-Channel-1 started
14240 [run-main] INFO itcm.JvmAmqpClient$ - ... RECEIVED:
14240 [run-main] INFO itcm.JvmAmqpClient$ - ###NULL###
14240 [run-main] INFO itcm.JvmAmqpClient$ - closing connection...
14240 [run-main] INFO org.apache.qpid.client.AMQSession - Closing session:
org.apache.qpid.client.AMQSession_0_10@5ba0d9
14240 [run-main] INFO org.apache.qpid.client.BasicMessageConsumer - Closing
consumer:1[21416300]
14241 [Dispatcher-Channel-1] INFO
org.apache.qpid.client.AMQSession.Dispatcher - Dispatcher-Channel-1 thread
terminating for channel 1:org.apache.qpid.client.AMQSession_0_10@5ba0d9
17517 [IoReceiver - /10.1.3.3:10002] WARN
org.apache.qpid.transport.SessionDelegate - CLOSED:
[ssn:"a7b91704-3c30-42b9-8fec-67205cbced31"]