Simplest way to read a Java MapMessage in .NET

I’m replacing an old TibRv system we have where the message producer is a Java application and the message consumer is a .NET application. Using a MapMessage seemed the most natural way to go, since that had a very similar interface to the TibRv libraries we had been using. After porting the Java applications over, it came time to port the .NET clients over. I’m far less comfortable in c# than I am in Java, but its not at all clear to me what the .NET API can do with my MapMessage.

Am I missing something in the documentation ( I hope I am), or do I have to roll my own using the binary payload and the SDTMap in the .NET API?

Thanks,

Jim

Not sure you have already seen this but it may help. There’s an example of how to handle a MapMessage in C#

// assuming that message is a reference to a received message

IMessage message = args.Message; /*args is a MessageEventArgs*/

ISDTContainer container = SDTUtils.GetContainer(message);

if (container != null && container is IMapContainer)

{

    // typecast the container to IMapContainer

    IMapContainer map = (IMapContainer) container;

}

It seems you can then iterate over the entries in the map using GetNext, HasNext and start over using Rewind once you iterated over all entries:

Thanks. That appears to be what I’m looking for. I’ll give it a try. I am not using a JMS MapMessage, but a Solace JCSMP MapMessage. It never occurred to me to look in the JMS API docs.

A JMS MapMessage is under the covers converted to a Solace MapMessage and you can handle is as such as far as I understand. Good luck!

Hi @fijimf … here’s a few other places to check:

            IMessage message = args.Message;
            ISDTContainer container = SDTUtils.GetContainer(message);
            StringBuilder sb = new StringBuilder();
            if (container is IMapContainer)
            {
                IMapContainer map = (IMapContainer)container;
                ...

Hope that helps!

Hello - I am working on .Net app, communicating with Java application. Java service is sending a Json response, stated they are sending MapMessage. Below is what I see in container, Is ‘m_opaqueContainer’ the actual message? If so how do I convert to string to be used in Json deserializer? Also, I was able to extract the message from ‘binaryAttachment’ of response but it has additional data which is not needed.

thanks in advance.

{SolaceSystems.Solclient.Messaging.Native.SDTMapContainerImpl}
m_isClosed: 0
m_opaqueContainer: {1946161133}
m_unmanagedByteBuffer: {0}
m_unmanagedByteBufferSize: 0