Announcement

Collapse
No announcement yet.

Passing java object to source from JMS queue in Mirth?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing java object to source from JMS queue in Mirth?

    I am passing java object from JMS sender client to mirth.Java Class look like this:

    Code:
    public class OrderDetails implements Serializable{
    
        private static final long serialVersionUID = -4617153110762983450L;
        private Long mrn;
        private Long orderNo;
        private Long patientId;
        private Long orderId;
        private Long encounterId;
    
    }
    JMS client code looks like this:

    Code:
    public void sendMessage(final OrderDetails orderDetails) throws JMSException {
            LOG.debug("Starting sendMessage of AMQMsgSenderService");
            jmsTemplate.send(new MessageCreator() {
                public Message createMessage(Session session) throws JMSException {
                    LOG.info("SENDING: " + orderDetails);
                    ObjectMessage message = session.createObjectMessage( orderDetails );
                    return message;
                }
            });
            LOG.debug("Ending sendMessage of AMQMsgSenderService");
        }
    Connector Type in Mirth is JMS Reader. I want to receive java object in source and transform into XML or JavaScript Object. Is it possible in Mirth?I am using Mirth Version 2.2.1.5861.
    Last edited by ashu84; 07-23-2013, 11:40 PM.

  • #2
    Can anyone give suggestion on this post please??

    Comment


    • #3
      What currently gets received by the channel? Or is there an error?
      Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

      Nicholas Rupley
      Work: 949-237-6069
      Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


      - How do I foo?
      - You just bar.

      Comment


      • #4
        I am getting following error:

        Code:
        [2013-07-25 02:41:24,405]  ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95): Caught exception in Exception Strategy for: e6c39215-2bca-41f5-8951-4b7a1092a850: org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#-1649715782', type='receiver', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
        org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#-1649715782', type='receiver', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
        	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:64)
        	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79)
        	at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487)
        	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266)
        	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225)
        	at com.mirth.connect.connectors.jms.JmsMessageReceiver.onMessage(JmsMessageReceiver.java:101)
        	at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
        	at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
        	at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
        	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
        	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        	at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.transformer.TransformerException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails (javax.jms.JMSException) (org.mule.umo.transformer.TransformerException)
        	at com.mirth.connect.connectors.jms.transformers.JMSMessageToObject.doTransform(JMSMessageToObject.java:66)
        	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
        	at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
        	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
        	... 13 moreCaused by: org.mule.umo.transformer.TransformerException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails (javax.jms.JMSException)
        	at com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.transformFromMessage(AbstractJmsTransformer.java:216)
        	at com.mirth.connect.connectors.jms.transformers.JMSMessageToObject.doTransform(JMSMessageToObject.java:60)
        	... 16 moreCaused by: javax.jms.JMSException: Failed to transform message: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: com.nous.domain.OrderDetails
        	at com.mirth.connect.connectors.jms.JmsMessageUtils.getObjectForMessage(JmsMessageUtils.java:158)
        	at com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.transformFromMessage(AbstractJmsTransformer.java:213)
        	... 17 more
        I have attached the exported XML file for the channel.
        Attached Files

        Comment


        • #5
          Hi Narupley,

          Now i have resolved the previous error.I have created the jar file for class whose object i was getting passed and placed in custom-lib folder of mirth connect.
          Now when i am logging that object in source transformer by doing this :

          Code:
          logger.info("orderDetails " +messageObject.getRawData());


          It is printing this :

          orderDetails [email protected]

          After this i am trying to access one property of that object by calling the getter method:

          Code:
          var orders  = messageObject.getRawData();
          logger.info("orderDetails mrn" +orders.getMrn());


          Now i am getting following error :

          Code:
          [2013-07-26 07:37:29,760]  ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95): Caught exception in Exception Strategy for: e6c39215-2bca-41f5-8951-4b7a1092a850: org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#663859136', type='receiver', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
          org.mule.umo.routing.RoutingException: Failed to transform message before applying the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://TEST.Q1, transformer=Transformer{name='JMSMessageToObject', returnClass=false, returnClass=false, sourceTypes=[interface javax.jms.Message]}, name='_jmsEndpoint#663859136', type='receiver', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: org.apache.activemq.command.ActiveMQObjectMessage
          	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:64)
          	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:79)
          	at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.java:487)
          	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:266)
          	at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:225)
          	at com.mirth.connect.connectors.jms.JmsMessageReceiver.onMessage(JmsMessageReceiver.java:101)
          	at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
          	at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
          	at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
          	at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
          	at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          	at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.transformer.TransformerException: CHANNEL:
          	JavaObjectIncomingChannelCONNECTOR:
          	sourceConnectorSCRIPT SOURCE:
          	SOURCE CODE:
          	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
          	12DETAILS:
          	TypeError: Cannot find function getMrn in object [email protected] (com.mirth.connect.server.MirthJavascriptTransformerException) (org.mule.umo.transformer.TransformerException)
          	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:316)
          	at org.mule.transformers.AbstractEventAwareTransformer.doTransform(AbstractEventAwareTransformer.java:48)
          	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:197)
          	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
          	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
          	at org.mule.transformers.AbstractTransformer.transform(AbstractTransformer.java:200)
          	at org.mule.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
          	at org.mule.routing.inbound.SelectiveConsumer.isMatch(SelectiveConsumer.java:61)
          	... 13 moreCaused by: org.mule.umo.transformer.TransformerException: CHANNEL:
          	JavaObjectIncomingChannelCONNECTOR:
          	sourceConnectorSCRIPT SOURCE:
          	SOURCE CODE:
          	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
          	12DETAILS:
          	TypeError: Cannot find function getMrn in object [email protected] (com.mirth.connect.server.MirthJavascriptTransformerException)
          	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:410)
          	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.transform(JavaScriptTransformer.java:296)
          	... 20 moreCaused by: com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL:
          	JavaObjectIncomingChannelCONNECTOR:
          	sourceConnectorSCRIPT SOURCE:
          	SOURCE CODE:
          	7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);8: 9: 10: logger.info("orderDetails " +messageObject.getRawData());11: var orders  = messageObject.getRawData();12: logger.info("orderDetails mrn" +orders.getMrn());13: 14: }LINE NUMBER:
          	12DETAILS:
          	TypeError: Cannot find function getMrn in object [email protected]
          	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:398)
          	... 21 more
          Please help me on this.I am using Mirth Version 2.2.1.5861. I have attached the exported XML file for the channel for the reference.

          Waiting for the reply

          Comment

          Working...
          X