# Simplest way to read a Java MapMessage in .NET

**URL:** <https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372>\
**Category:** General Discussions\
**Created:** [August 19, 2020, 9:37pm UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372 "2020-08-19T21:37:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fijimf](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/fijimf/32/1389_2.png) [@fijimf](https://community.solace.com/u/fijimf)\
**Post date:** [August 19, 2020, 9:37pm UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/1 "2020-08-19T21:37:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swenhelge](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/swenhelge/32/2201_2.png) [@swenhelge](https://community.solace.com/u/swenhelge)\
**Post date:** [August 20, 2020, 8:57am UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/2 "2020-08-20T08:57:27Z")

</div>

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

> **[JMS API](https://docs.solace.com/API/Solace-JMS-API/jms-get-started-open.htm)**

```auto
// 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:

> **[IMapContainer Interface](https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/fe47d7d1-f581-1059-d6e8-aaad2c1dc5cb.htm)**
>
> Represents a Structured Data Type (SDT) map container. Very similar to a hash map with one notable exception. IMapContainer does not detect duplicate key names on 'add'.

---

<div class="post-metadata">

**Author:** ![fijimf](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/fijimf/32/1389_2.png) [@fijimf](https://community.solace.com/u/fijimf)\
**Post date:** [August 20, 2020, 1:46pm UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/3 "2020-08-20T13:46:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![swenhelge](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/swenhelge/32/2201_2.png) [@swenhelge](https://community.solace.com/u/swenhelge)\
**Post date:** [August 20, 2020, 1:48pm UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/4 "2020-08-20T13:48:15Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Aaron](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/aaron/32/843_2.png) [@Aaron](https://community.solace.com/u/Aaron)\
**Post date:** [August 25, 2020, 4:30am UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/5 "2020-08-25T04:30:15Z")

</div>

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

- From [docs.solace.com](http://docs.solace.com), under APIs, C#: [C# / .NET API](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 [SolaceSystems.Solclient.Messaging.SDT Namespace](https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/a9ff5698-73ec-6664-3b83-973e092cd43d.htm)
- From [https://solace.com/downloads/](https://solace.com/downloads/) : download the .NET samples package, and check out the `SDTPubSubMsgDep.cs` sample located in the “ex” folder:

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

```

Hope that helps!

---

<div class="post-metadata">

**Author:** ![mohan](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mohan](https://community.solace.com/u/mohan)\
**Post date:** [February 10, 2021, 2:48am UTC](https://community.solace.com/t/simplest-way-to-read-a-java-mapmessage-in-net/372/6 "2021-02-10T02:48:01Z")

</div>

> [@Aaron](#):
>
> Hi @fijimf … here’s a few other places to check:
> 
> - From [docs.solace.com](http://docs.solace.com), under APIs, C#: [C# / .NET API](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 [SolaceSystems.Solclient.Messaging.SDT Namespace](https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/a9ff5698-73ec-6664-3b83-973e092cd43d.htm)
> - From [https://solace.com/downloads/](https://solace.com/downloads/) : download the .NET samples package, and check out the `SDTPubSubMsgDep.cs` sample located in the “ex” folder:
> 
> ```auto
> 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
