Hi,

I have got an MDB that has to resend the message received by the onMessage() 
method to another queue. Additionally, I want to use a container managed 
transaction for this send operation.

Using the following code, everything works fine if I try to send to a local 
queue on the same JBoss: 

  | public void onMessage(Message message) {
  | ...
  |    Context ctx = new InitialContext();
  |    Queue queue = (Queue)ctx.lookup("QueueName");
  |    QueueConnectionFactory queueFactory = 
(QueueConnectionFactory)ctx.lookup("java:/JmsXA");
  |    QueueConnection connection = 
queueFactory.createQueueConnection("username", "password");
  |    QueueSession session = connection.createQueueSession(true, -1);
  |    QueueSender sender = session.createSender(queue);
  |    sender.send(queue, message);
  | ...
  | }
  | 

If I try to connect to a remote queue everything seems to be OK for the MDB and 
it exits without any exception.
However, the message never reaches the remote queue because the send operation 
managed by the container fails. From the log files I could see that my JBoss 
tried to resend the message many times until I stopped it.
The code for the remote case looks like this:

  | public void onMessage(Message message) {
  | ...
  |    Properties env = new Properties();
  |    env.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
  |    env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  |    env.put(Context.PROVIDER_URL, "jnp://remotehost:1299");
  |  
  |    Context remoteCtx = new InitialContext(env);
  |    Queue queue = (Queue)remoteCtx.lookup("QueueName");
  |    QueueConnectionFactory queueFactory = 
(QueueConnectionFactory)remoteCtx.lookup("java:/JmsXA");
  |    QueueConnection connection = 
queueFactory.createQueueConnection("username", "password");
  |    QueueSession session = connection.createQueueSession(true, -1);
  |    QueueSender sender = session.createSender(queue);
  |    sender.send(queue, message);
  | ...
  | }
  | 

If I switch off transaction by

  |    QueueSession session = connection.createQueueSession(false, 
QueueSession.AUTO_ACKNOWLEDGE);
  | 
message sending works as expected. But I have no transaction handling this way.

I also tested an XAConnectionFactory instead of JmsXA which makes no difference 
and does not work, too.

Has anybody an idea or perhaps a better running solution?


Thanks in advance!



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974619#3974619

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974619
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to