1 Reply Latest reply on Sep 1, 2004 1:34 PM by Adrian Brock

    getJMSCorrelationIDAsBytes()

    Bruce Cohen Newbie

      We have an small MDB deployed to JBoss 3.2.3. The MDB consumes messages from a external JMS provider queue (Tibco 4.1)

      The MDB attempts to re-publish the message using JBoss MQ

      The MDB looks roughly like:

      public void onMessage(Messasge msgFromTibco){
      jbossQueueSender_.send(msgFromTibco);
      }

      Because Tibco doesn't implement the getJMSCorrelationIDAsBytes()
      the send() method throws an UnsupportedOperationException:

      (According to the JMS spec, its legal for implementations of the Message
      interface to have getJMSCorrelationIDAsBytes() methods which throw
      UnsupportedOperationException)

      Here's the stack trace:

      TransactionRolledbackLocalException in method: public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message), causedBy:
      java.lang.UnsupportedOperationException: CorrelationID as byte array is not supported
      at com.tibco.tibjms.TibjmsMessage.getJMSCorrelationIDAsBytes(TibjmsMessage.java:345)
      at org.jboss.mq.SpyEncapsulatedMessage.setMessage(SpyEncapsulatedMessage.java:30)
      at org.jboss.mq.SpyQueueSender.internalSend(SpyQueueSender.java:113)
      at org.jboss.mq.SpyQueueSender.send(SpyQueueSender.java:68)
      at test.ejb.MessageReceiverMDB.publish(MessageReceiverMDB.java:284)
      at .test.ejb.MessageReceiverMDB.onMessage(MessageReceiverMDB.java:85)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:460)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:374)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:824)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1114)
      at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      at com.tibco.tibjms.TibjmsSession._submit(TibjmsSession.java:2843)
      at com.tibco.tibjms.TibjmsSession._dispatchAsyncMessage(TibjmsSession.java:1428)
      at com.tibco.tibjms.TibjmsSession._run(TibjmsSession.java:2469)
      at com.tibco.tibjms.TibjmsSession.run(TibjmsSession.java:3404)
      at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:727)
      at java.lang.Thread.run(Thread.java:552)


      Looking at the JBoss 3.2.3 SpyEncapsulatedMessage.java, in the setMessage() method I see:


      setJMSCorrelationID( m.getJMSCorrelationID() );
      setJMSCorrelationIDAsBytes( m.getJMSCorrelationIDAsBytes() );

      Later versions (4.0) have the following in setMessage()

      if (m.getJMSCorrelationID() != null)
      setJMSCorrelationID(m.getJMSCorrelationID());
      else if (m.getJMSCorrelationIDAsBytes() != null)
      setJMSCorrelationIDAsBytes(m.getJMSCorrelationIDAsBytes());

      So if I use a later version *AND* set a correlation ID I should avoid the
      exception.

      However, should the setMessage() implementation ignore/handle an UnsupportedOperationException since its possible/probable that a Message implementation will throw this?

      Thanks in advance,
      Bruce