You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by stevenbohrer <st...@cisco.com> on 2008/03/06 19:12:35 UTC

MAP_TYPE support in ActiveMQ CPP

I'm writing a new interface to a Java ActiveMQ application which uses
MAP_TYPE in it's messages.  

Active MQ CPP 2.1.3 does not seem to have support for this data type.  The
type is listed in PrimitiveMap.h, but
PrimitiveMapMarshaller::marshalPrimitive does not have a handler for it.

Any suggestions?


-- 
View this message in context: http://www.nabble.com/MAP_TYPE-support-in-ActiveMQ-CPP-tp15880324s2354p15880324.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: MAP_TYPE support in ActiveMQ CPP

Posted by stevenbohrer <st...@cisco.com>.
Hi Tim,

I tried the suggested fix, but that seems to address the outgoing
MapMessage.  Regardless, it didn't resolve my issue.

As far as I can tell through the debugger, I'm receiving the map message
fine and unmarshaling the data into the PrimitiveMap properties private
variable OK.  But since the ActiveMQMapMessage type requires it's
PrimitiveMap* map variable to be set (rather than the base class
"properties"), the data is not read at the client level.  

I worked around the problem by overriding the afterUnmarshal function in
ActiveMQMapMessage class and copying the data, but I'm not sure what the
original intent was here, and don't want to change something
inappropriately.


-- 
View this message in context: http://www.nabble.com/MAP_TYPE-support-in-ActiveMQ-CPP-tp15880324s2354p15967728.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: MAP_TYPE support in ActiveMQ CPP

Posted by Timothy Bish <ta...@gmail.com>.
If you create patches you can attach them to this issue:
https://issues.apache.org/activemq/browse/AMQCPP-172

You can compare the current version of ActiveMQMapMessage to the
previous one in SVN to find the changes.

Version 2.2 is not yet released.

To save you some time, here is the basic fix change copyDataStructure to
look like this.  Note that this was only a bug when using the async
transport.

        virtual void copyDataStructure( const DataStructure* src ) {

ActiveMQMessageBase<cms::MapMessage>::copyDataStructure( src );

            const ActiveMQMapMessage* srcMap =
                dynamic_cast< const ActiveMQMapMessage* >( src );

            if( srcMap != NULL && srcMap->map != NULL ) {
                this->map = new util::PrimitiveMap( *srcMap->map );
            }
        }


On Mon, 2008-03-10 at 00:40 -0700, stevenbohrer wrote:
> Hi Tim,
> 
> I've implemented the Map and List types now, and will work on submitting
> them with the proper tests, etc.  However, I have another issue, I'm using a
> Topic with MapMessages, and they don't seem to be received properly.  I
> found https://issues.apache.org/activemq/browse/AMQCPP-166 which seems to
> describe the same problem, and notes it was resolved in V2.2.  Is that
> version available yet?  If not (and I hope this isn't too much of a pain),
> can you send me the fix, or tell me how to resolve the issue?
> 
> Thanks,
> 
> Steve
> 
> 


Re: MAP_TYPE support in ActiveMQ CPP

Posted by stevenbohrer <st...@cisco.com>.
Hi Tim,

I've implemented the Map and List types now, and will work on submitting
them with the proper tests, etc.  However, I have another issue, I'm using a
Topic with MapMessages, and they don't seem to be received properly.  I
found https://issues.apache.org/activemq/browse/AMQCPP-166 which seems to
describe the same problem, and notes it was resolved in V2.2.  Is that
version available yet?  If not (and I hope this isn't too much of a pain),
can you send me the fix, or tell me how to resolve the issue?

Thanks,

Steve


-- 
View this message in context: http://www.nabble.com/MAP_TYPE-support-in-ActiveMQ-CPP-tp15880324s2354p15950588.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: MAP_TYPE support in ActiveMQ CPP

Posted by Timothy Bish <ta...@gmail.com>.
A list is just what it sounds like.  If you look at the code in the Java
src you can see that they are just written as a series of primitives,
with a leading size.  Should be pretty simple to take this logic and
insert it into the PrimitiveMapMarshaler.


    public static void marshalPrimitiveList(List list, DataOutputStream
out) throws IOException {
        out.writeInt(list.size());
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Object element = (Object)iter.next();
            marshalPrimitive(out, element);
        }
    }

    public static List<Object> unmarshalPrimitiveList(DataInputStream
in) throws IOException {
        int size = in.readInt();
        List<Object> answer = new ArrayList<Object>(size);
        while (size-- > 0) {
            answer.add(unmarshalPrimitive(in));
        }
        return answer;
    }


On Thu, 2008-03-06 at 14:11 -0800, stevenbohrer wrote:
> Tim, 
> 
> As suggested, I'll continue this correspondence in this thread.
> 
> I decided to just modify the PrimitiveMap.* and MarshalPrimitiveMap.* files
> in a manner consistent with what had already been done.  The java example I
> saw didn't mesh well with the cpp files.  This is now completed and seems to
> be working (checking it in, testing, etc, will be on the backburner for
> awhile)
> 
> However, I have another problem.  Apparently we are using LIST_TYPE as well
> and that is not supported in ActiveMQ CPP either.  I don't understand this
> type nearly as well.  Are we simply talking about a Map without key names?
> 
> 


Re: MAP_TYPE support in ActiveMQ CPP

Posted by stevenbohrer <st...@cisco.com>.
Tim, 

As suggested, I'll continue this correspondence in this thread.

I decided to just modify the PrimitiveMap.* and MarshalPrimitiveMap.* files
in a manner consistent with what had already been done.  The java example I
saw didn't mesh well with the cpp files.  This is now completed and seems to
be working (checking it in, testing, etc, will be on the backburner for
awhile)

However, I have another problem.  Apparently we are using LIST_TYPE as well
and that is not supported in ActiveMQ CPP either.  I don't understand this
type nearly as well.  Are we simply talking about a Map without key names?


-- 
View this message in context: http://www.nabble.com/MAP_TYPE-support-in-ActiveMQ-CPP-tp15880324s2354p15885358.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: MAP_TYPE support in ActiveMQ CPP

Posted by Timothy Bish <ta...@gmail.com>.
We are always willing to accept code contributions.  :)

Currently there is no one working on that, you could create a Jira issue
to document that someone is interested in such support and it may get
added in the future.  Looking at the map and list encoding it should be
pretty easy to implement, I just don't think anyone has needed it yet.

Regards
Tim.

On Thu, 2008-03-06 at 10:12 -0800, stevenbohrer wrote:
> I'm writing a new interface to a Java ActiveMQ application which uses
> MAP_TYPE in it's messages.  
> 
> Active MQ CPP 2.1.3 does not seem to have support for this data type.  The
> type is listed in PrimitiveMap.h, but
> PrimitiveMapMarshaller::marshalPrimitive does not have a handler for it.
> 
> Any suggestions?
> 
>