Announcement

Collapse
No announcement yet.

Adding String properties to a message in a JMS destination

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

  • Adding String properties to a message in a JMS destination

    Hi,
    I've been able to successfully connect to my openMQ broker with the JMS Writer destination and send a TextMessage and I'm trying to understand how I can add a string property to the sent message?
    (i.e. the receiving end will be able to do msg.getStringProperty("keyIEntered") and receive that value).
    I have a hunch that this can be acheived in the postprocessing scripts but I'm not really sure.
    Has anyone done that?
    If so I'd really appreciate learning how.

    Thanks in advance,
    Ittai

  • #2
    Hi;

    Anything done in your post processor will happen after your message has left Mirth, so you need to do this in your destination.

    I've never tried, but does the .setStringProperty method work? I've seen a reference to it in the Mozilla documentation.
    I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
    http://www.linkedin.com/pub/david-rothbauer/5/923/518
    codeismydrug.wordpress.com
    hl7coders.wordpress.com

    Test all my code suggestions prior to implementation

    Comment


    • #3
      Hi,
      Thanks for your reply (I wasn't sure how active the community is).
      I see what you mean about the postProcessor and so I went to the destination and added a step in the transformer of the JavaScript type.
      There I tried both:
      Code:
      message.setStringProperty('testKey','testValue');
      and
      Code:
      message.setStringProperty("testKey","testValue");
      And after placing a message I received the following error:
      Code:
      ERROR 2011-08-25 08:48:13,282 [cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_source_connector._fileEndpoint#508194636.receiver.1] org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in Exception Strategy for: cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5: org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.mirth.connect.model.MessageObject
      org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.mirth.connect.model.MessageObject
      	at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:84)
      	at org.mule.impl.model.DefaultMuleProxy.onCall(DefaultMuleProxy.java:247)
      	at org.mule.impl.model.seda.SedaComponent.doSend(SedaComponent.java:209)
      	at org.mule.impl.model.AbstractComponent.sendEvent(AbstractComponent.java:277)
      	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:201)
      	at org.mule.routing.inbound.InboundMessageRouter.send(InboundMessageRouter.java:176)
      	at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:143)
      	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.file.FileMessageReceiver.processFile(FileMessageReceiver.java:228)
      	at com.mirth.connect.connectors.file.FileMessageReceiver.poll(FileMessageReceiver.java:118)
      	at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:97)
      	at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
      	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
      	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: org.mule.umo.routing.CouldNotRouteOutboundMessageException: Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://CE_Fake, transformer=Transformer{name='cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_destination_2_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_jmsEndpoint#1652802880', type='sender', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.mirth.connect.model.MessageObject
      	at org.mule.routing.outbound.FilteringMulticastingRouter.route(FilteringMulticastingRouter.java:72)
      	at org.mule.routing.outbound.OutboundMessageRouter$1.doInTransaction(OutboundMessageRouter.java:78)
      	at org.mule.transaction.TransactionTemplate.execute(TransactionTemplate.java:48)
      	at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:82)
      	... 16 more
      Caused by: org.mule.umo.provider.DispatchException: Failed to route event via endpoint: ImmutableMuleEndpoint{[email protected], endpointUri=jms://CE_Fake, transformer=Transformer{name='cb8ddd5b-4a62-4e28-b7d1-3f3b7506e3f5_destination_2_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_jmsEndpoint#1652802880', type='sender', properties={}, [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.mirth.connect.model.MessageObject
      	at org.mule.providers.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:177)
      	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:191)
      	at org.mule.impl.MuleSession.sendEvent(MuleSession.java:130)
      	at org.mule.routing.outbound.AbstractOutboundRouter.send(AbstractOutboundRouter.java:85)
      	at org.mule.routing.outbound.FilteringMulticastingRouter.route(FilteringMulticastingRouter.java:54)
      	... 19 more
      Caused by: org.mule.umo.transformer.TransformerException: 
      CHANNEL:	mock sender
      CONNECTOR:	Destination 2
      SCRIPT SOURCE:	
      SOURCE CODE:	
      5: msg = new XML(newMessage);
      6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
      7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
      8: 
      9: 
      10: message.setStringProperty("testKey","testProperty");
      11: 
      12: }
      LINE NUMBER:	10
      DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>. (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.impl.MuleEvent.getTransformedMessage(MuleEvent.java:251)
      	at com.mirth.connect.server.controllers.DefaultMessageObjectController.getMessageObjectFromEvent(DefaultMessageObjectController.java:785)
      	at com.mirth.connect.connectors.jms.JmsMessageDispatcher.dispatchMessage(JmsMessageDispatcher.java:85)
      	at com.mirth.connect.connectors.jms.JmsMessageDispatcher.doSend(JmsMessageDispatcher.java:252)
      	at org.mule.providers.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:164)
      	... 23 more
      Caused by: org.mule.umo.transformer.TransformerException: 
      CHANNEL:	mock sender
      CONNECTOR:	Destination 2
      SCRIPT SOURCE:	
      SOURCE CODE:	
      5: msg = new XML(newMessage);
      6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
      7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
      8: 
      9: 
      10: message.setStringProperty("testKey","testProperty");
      11: 
      12: }
      LINE NUMBER:	10
      DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>. (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)
      	... 30 more
      Caused by: com.mirth.connect.server.MirthJavascriptTransformerException: 
      CHANNEL:	mock sender
      CONNECTOR:	Destination 2
      SCRIPT SOURCE:	
      SOURCE CODE:	
      5: msg = new XML(newMessage);
      6: if (msg.namespace("") != undefined) { default xml namespace = msg.namespace(""); } else { default xml namespace = ''; }
      7: function doFilter() { phase = 'filter'; return true; }function doTransform() { phase = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase);
      8: 
      9: 
      10: message.setStringProperty("testKey","testProperty");
      11: 
      12: }
      LINE NUMBER:	10
      DETAILS:	TypeError: Cannot find function setStringProperty in object <?xml version="1.0" encoding="UTF-8"?><HL7Message>...</HL7Message>.
      	at com.mirth.connect.server.mule.transformers.JavaScriptTransformer.evaluateScript(JavaScriptTransformer.java:398)
      	... 31 more
      I'm not sure what you mean by the Mozilla documentation?

      Thanks again for your help
      Last edited by Ittai; 08-25-2011, 01:03 AM. Reason: Typo

      Comment

      Working...
      X