You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by HubbaBubba <st...@csiro.au> on 2014/04/17 06:54:27 UTC
MySQL column MSG format
Hi all,
I'm using activeMQ v5.6 and connecting a simple chat application using
ws+stomp. Ideally I would like to input the chat messages into the connected
MySQL database (table activemq.activemq_msgs) as an XML object, however,
looking at the messages in the MySQL table, it seems this is not entirely
the case:
MSG: J { /ID:hostname-55969-1397709076980-2:3 ????????e chat n{
/ID:hostname-55969-1397709076980-2:3 ???????? c
Em?W W<message type="chat" from="fred" text="This is a test."
time="1397709362949"/> Em?W
I understand one can change the default MySQL column definition in newer
version of activeMQ via <statements binaryDataType ="?"/>, but this is not
an option for me. I wonder if others have thought of another way?
Thanks in advance.
--
View this message in context: http://activemq.2283324.n4.nabble.com/MySQL-column-MSG-format-tp4680378.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: MySQL column MSG format
Posted by HubbaBubba <st...@csiro.au>.
Thank you all for the tips.
I guess if I am only issuing SELECT statements to view a chat history, the
impact on the database should be minimal. I could always create an ON INSERT
trigger to copy messages from the ACTIVEMQ_MSGS table to one not used by
ActiveMQ directly.
If I bound the message in a <message type="" text="" time=""/> tag, I can
extract the message details from the LongBLOB as follows:
select SUBSTRING_INDEX(SUBSTRING_INDEX(MSG,'<message',-1),'/>',1) from
activemq_msgs;
Cheers.
--
View this message in context: http://activemq.2283324.n4.nabble.com/MySQL-column-MSG-format-tp4680378p4680435.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: MySQL column MSG format
Posted by artnaseef <ar...@artnaseef.com>.
Also, please be careful about using the DB for direct access to the messages;
this is looking into the private internals of ActiveMQ.
If this is for a tool to diagnose or understand ActiveMQ internals, that's
cool. If it's for the application logic, it could be very bad. For
example, consider what happens when coordination between database accesses
is lacking and needed. Or, if the application starts locking tables and
rows, blocking ActiveMQ operations.
It should be relatively easy to consume messages in an application and write
the contents to a database. With camel, it's probably about 2 dozen lines
(configuring the DB and activemq connections and endpoints). Something to
consider...
Remember, there's a certain amount of complexity every solution to a
specific problem will require. Simplifying the solution in one place moves
that complexity to another. It's important to choose appropriate places for
that complexity. Is it wise to have the chat application's messages stored
in the same DB as ActiveMQ's messages to simplify the task of getting them
stored, at the cost of putting that added complexity in the messaging layer
and possibly interfering with the operation of the messaging layer (not to
mention creation of a circular dependency)?
--
View this message in context: http://activemq.2283324.n4.nabble.com/MySQL-column-MSG-format-tp4680378p4680389.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: MySQL column MSG format
Posted by Gary Tully <ga...@gmail.com>.
you really need a custom persistence adapter b/c the message blob is
the marshalled message (marshalled with opewire) so the same encoding
as we use on the wire by default.
peek at: https://github.com/apache/activemq/blob/trunk/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/JDBCMessageStore.java#L117
You would need to use an XML marshaller like we do for the http transport.
see: org.apache.activemq.transport.xstream.XStreamWireFormat
all of the statements can be changed via xml configuration (peek at
the schema) - so it should be possible to modify the blob type
On 17 April 2014 05:54, HubbaBubba <st...@csiro.au> wrote:
> Hi all,
>
> I'm using activeMQ v5.6 and connecting a simple chat application using
> ws+stomp. Ideally I would like to input the chat messages into the connected
> MySQL database (table activemq.activemq_msgs) as an XML object, however,
> looking at the messages in the MySQL table, it seems this is not entirely
> the case:
>
> MSG: J { /ID:hostname-55969-1397709076980-2:3 ????????e chat n{
> /ID:hostname-55969-1397709076980-2:3 ???????? c
> Em?W W<message type="chat" from="fred" text="This is a test."
> time="1397709362949"/> Em?W
>
>
> I understand one can change the default MySQL column definition in newer
> version of activeMQ via <statements binaryDataType ="?"/>, but this is not
> an option for me. I wonder if others have thought of another way?
>
> Thanks in advance.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/MySQL-column-MSG-format-tp4680378.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
--
http://redhat.com
http://blog.garytully.com