[openamq-dev] OpenAMQ JMS via Spring JmsTemplate
openamq at athieme.com
openamq at athieme.com
Mon Apr 28 20:49:45 CEST 2008
I apologize if this has already been answered; but, can anyone give
pointers on getting the following to work. I have the server running, am
able to telnet to port 5672 (as a test); but, I get the errors included
below. The goal would be to expose only the JmsTemplate for send and
receive to my code. That is, my code will not have direct access to the
connaction facotry, session, connection, message consumer or creator (all
access is wrapped by the JmsTemplate).
import org.openamq.AMQException;
import org.openamq.client.AMQConnectionFactory;
import org.openamq.client.AMQQueue;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
/**
* @author Athieme
*/
public class OpenAmqTest {
public static void main(String[] aStrArg) throws JMSException, AMQException
{
String host = aStrArg[0];
int port = Integer.valueOf(aStrArg[1]);
String path = aStrArg[2];
String queue = aStrArg[3];
final String message = aStrArg[4];
AMQConnectionFactory factory = new AMQConnectionFactory();
factory.setDefaultUsername("guest");
factory.setDefaultPassword("guest");
factory.setHost(host);
factory.setPort(port);
factory.setVirtualPath(path);
AMQQueue destination = new AMQQueue(queue);
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(factory);
jmsTemplate.setDefaultDestination(destination);
jmsTemplate.send(new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
TextMessage textMessage = (TextMessage)jmsTemplate.receive();
System.out.println(textMessage.getText());
}
}
// confirmation server is running
ibase> ./bin/amq_server
OpenAMQ/1.2c4
Production release
Copyright (c) 2007 iMatix Corporation
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2008-04-26 20:06:52: W: security warning - logins use default passwords
2008-04-26 20:06:52: I: server starting in non-clustered mode
2008-04-26 20:06:52: I: server binding to 127.0.0.1:5672
2008-04-26 20:06:53: I: server ready for incoming AMQ connections
// log from running test
main 2008-04-26 21:09:57,234 INFO
[openamq.client.transport.SocketTransportConnection] Attempting connection to
/192.168.183.2:5672
AnonymousIoService-1-1 2008-04-26 21:09:58,728 INFO
[openamq.client.security.CallbackHandlerRegistry] Available SASL mechanisms:
CRAM-MD5 PLAIN
AnonymousIoService-1-2 2008-04-26 21:10:08,888 INFO
[openamq.client.protocol.AMQProtocolHandler] Session closed called with
failover state currently FailoverState: NOT STARTED
AnonymousIoService-1-2 2008-04-26 21:10:08,889 INFO
[openamq.client.protocol.AMQProtocolHandler] Protocol Session
[org.openamq.client.protocol.AMQProtocolHandler at f7bf2d] closed
main 2008-04-26 21:10:08,890 INFO
[openamq.client.transport.SocketTransportConnection] Attempting connection to
/192.168.183.2:5672
// i also see this on the server
2008-04-26 20:09:54: I: cnn=0 msg=0 mem=0K/0K exc=8 que=0 csm=0 bnd=0 adx=0
idx=8 map=0
2008-04-26 20:09:54: I: qcn=0 cnq=0
2008-04-26 20:10:06: E: Channel error: 200 JMS client closing channel, closing
channel (192.168.183.101:61380, OpenAMQ/JMS, 1.2c1, proton.local1209258597139)
2008-04-26 20:10:06: E: Connection error: 200 JMS client is closing the
connection., closing connection (192.168.183.101:61380, OpenAMQ/JMS, 1.2c1,
proton.local1209258597139)
2008-04-26 20:10:54: I: cnn=1 msg=0 mem=0K/0K exc=8 que=1 csm=1 bnd=2 adx=0
idx=8 map=0
2008-04-26 20:10:54: I: qcn=1 cnq=1
More information about the openamq-dev
mailing list