Issue with MSMQ plugin

Hi,
I’m facing an issue using the MSMQ plugin. Let me describe you an example, to reproduce the problem.

  1. Create a not-transactional MSMQ private queue, named “customer” (italian UI, sorry!)
    image

  2. Into the Linx Designer solution, create a CustomType, customer, as following
    image

  3. Now create a process, to create and push a customer object into the customer queue


  4. Running the process, a brand new message is added to the customers queue, and the content looks like the following (that’s fine!)

  5. And now, create a process to simply pull this message out from the queue, using MsmqReceiveMessage function

You’ll run into this error: “Cannot deserialize the message passed as an argument. Cannot recognize the serialization format.”. And the message has been pulled out from queue and lost.

See attached solution.

Thank you in advance,
Ivan

temp.lsoz (4.6 KB)

Hi Ivan,

Thank you for the message. We will set up a server and test as well. Will let you know what we find.

Regards,
Dawie

Hi Ivan,

We were able to reproduce the issue and we are looking into a resolution.

We will keep you updated on the progress.

Hi Ivan,

The “bug” relates to how the message is initially sent to the queue, depending on this format it will try to return the same.

When sending a message to the queue, Linx looks at the format of the data that is going to be sent. If the item is serializable (i.e. a CustomType), Linx uses an XmlMessageFormatter to serialize the data, otherwise it uses a BinaryMessageFormatter. In this case, the data was sent using the XML formatter.

The reader currently only supports the Binary format, hence the error (trying to read XML data instead of binary data).

If you want to send a complex object, i.e. Customer, you can use the following workaround :

I’ve attached a sample: MSMQ_SampleSolution.lsoz (6.8 KB)

1) Pushing a Message (In sample solution: PushCustomer_WORKAROUND)
1.1) Define your custom type like before
1.2) Add a JsonWriter function below the local instance of the CustomType (Customer). For the properties of the JsonWriter, for the Data, just refer to the CustomType (Customer).
1.3) Below the JsonWriter you can use the MsmqSendMessage function. In here, for the message body, just refer to the output of the JsonWriter.

The process will now send a Json string as the message body.

2) Pulling a Messsage (In sample solution: PullCustomer_WORKAROUND)
2.1) Use a MsmqReceiveMessage function like before.
2.2) Below the function, add a local instance of the CustomType (Customer). Assign the value as the output from the MsmqReceiveMessage function.

You will now see the CustomType (Customer) is populated with the message details.

We are probably not going to support reading XML formatted messages in the foreseeable future.

If you have any more questions/issues, feel free to ask.

Hi Ronan,

Thank you for your reply.

Your workaround certainly works, but unfortunately my queue is shared with other custom application whom using Xml formatted messages.

Hi Ivan,

The development team has been looking into the issue with MSMQ and decided to make some changes on the plugin. The changes will allow the user to send or receive any format, including the XML. It should take a couple of weeks to implement. Will let you know once it’s available.

Regards,
Dawie

1 Like

Hi Dawie,

It sounds great!

Thank you all,
Ivan

Hi @igiordani

The MSMQ Plugin has had its functionality upgraded to handle sending and receiving of objects in the XML and Binary formats. If you do not have the latest release, you can always just update your MSMQ plugin version separately.

The change is noticeable when setting the properties for the MsmqSendMessage/MsmqReceiveMessage functions. There is an option for “Message format” which can either be XML or Binary (The Receive configuration will have to match the Send configuration format).

MsmqSendMessage
When adding a message to the message queue, using your example, you can create a local instance of the CustomType Customer and populate it with data. Then, when you are configuring the function properties, select the “Message format” that you would like to send it as (XML or Binary):
image

image

MsmqReceiveMessage
Similar to sending a message, when receiving a message you must specify what format you want to receive it as. Furthermore, in the “Output type” property you must set it appropriately (If Format is XML then set the output type as the CustomType you created and are expecting to receive, if Binary then set the output type to Byte).

image

If you have any further issues/questions just let us know.

2 Likes

Hi Ronan, it’s works perfectly! Thank you so much!

1 Like