Marshalling of java object to XML in Preprocessor phase of Mirth?

Mirth is receiving java object from ActiveMQ JMS Topic.I have set source connector inbound data type to Delimited Text in Mirth Channel and Connector Type is JMS Reader. Now in preprocessor phase i want to marshal this java object into XML.I have put logger like this"incoming data "+message);

And it is printing OrderDetails@240aaf81

Now i am calling custom java class for marshaling java object into XML.But this incoming message is converted to String by Mirth.Code in preprocessor script looks like this :

// Modify the message variable below to pre process data"incoming data "+message);
var object = new Packages.coms.controller.JAXBMarshalling();
return message;

While passing incoming message to method it is showing error that method does not exist because method expects custom java object as method parameter,but it going as String. Method looks like this:

public  void marshallJavaObjectToXml(OrderDetails orderDetails) {
        JAXBContext jaxbContext;
        try {
            File file = new File(
                    "C:\\Program Files (x86)\\Mirth Connect\\conf\\xml\\xmlrepresentation.xml");
            jaxbContext = JAXBContext.newInstance(OrderDetails.class);
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
            // output pretty printed
            jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            jaxbMarshaller.marshal(orderDetails, file);
            jaxbMarshaller.marshal(orderDetails, System.out);
        } catch (JAXBException e) {
            // TODO Auto-generated catch block

Class which object is passed looks like this:

    public class OrderDetails implements Serializable{

        private static final long serialVersionUID = -4617153110762983450L;
        private Long mrn;
        private Long orderNo;
        private Long patientId;
        private Long orderId;**strong text**
        private Long encounterId;

I have created jar file with these two classes and put in custom-lib folder of Mirth.How can i get the actual java object in preprocessor script of Mirth? I am using Mirth version


Such result can be achieved using the Attachment script on the Summary tab. There you deal with a message in its raw format. You can extract your object there and store it to the Global Channel Map which also allows passing objects, contrary to other two maps. The Preprocessor script handles the raw message as well. The difference between these two is that message is not stored in the database when it hits the Attachment handler, but it's stored after.

As a further reading I would recommend the "Unofficial Mirth Connect Developer's Guide". (Disclaimer: I'm the author of this book.)

Need Your Help

How to display image thumbnail instead in umbraco xslt?

image xslt thumbnails umbraco

Is there any way to display image thumb in xslt in umbraco?

C++ - Convert String to Char

c++ string char type-conversion

I was wondering if there is a way to convert from a string object into a char. For example:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.