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
Comments
-
Not sure you have already seen this but it may help. There's an example of how to handle a MapMessage in C#
https://docs.solace.com/Solace-JMS-API/Creating-JMS-Compatible-Msgs.htm#creating_jms-compatible_msgs_1946471526_329687// 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 usingRewind
once you iterated over all entries:
https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/fe47d7d1-f581-1059-d6e8-aaad2c1dc5cb.htm1 -
Hi @fijimf ... here's a few other places to check:
- From docs.solace.com, under APIs, C#: https://docs.solace.com/Solace-PubSub-Messaging-APIs/dotNet-API/net-api-home.htm#Features
- "Structured data types that allow interoperability between various architectures and programming languages"
- Inside the API reference: Solclient.Messaging.SDT https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/a9ff5698-73ec-6664-3b83-973e092cd43d.htm
- From https://solace.com/downloads/ : download the .NET samples package, and check out the
SDTPubSubMsgDep.cs
sample located in the "ex" folder:
IMessage message = args.Message; ISDTContainer container = SDTUtils.GetContainer(message); StringBuilder sb = new StringBuilder(); if (container is IMapContainer) { IMapContainer map = (IMapContainer)container; ...
Hope that helps!
1 - From docs.solace.com, under APIs, C#: https://docs.solace.com/Solace-PubSub-Messaging-APIs/dotNet-API/net-api-home.htm#Features
-
@Aaron said:
Hi @fijimf ... here's a few other places to check:- From docs.solace.com, under APIs, C#: https://docs.solace.com/Solace-PubSub-Messaging-APIs/dotNet-API/net-api-home.htm#Features
- "Structured data types that allow interoperability between various architectures and programming languages"
- Inside the API reference: Solclient.Messaging.SDT https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/a9ff5698-73ec-6664-3b83-973e092cd43d.htm
- From https://solace.com/downloads/ : download the .NET samples package, and check out the
SDTPubSubMsgDep.cs
sample located in the "ex" folder:
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: 00 - From docs.solace.com, under APIs, C#: https://docs.solace.com/Solace-PubSub-Messaging-APIs/dotNet-API/net-api-home.htm#Features