Kirill Dubovikov
Kirill Dubovikov

Reputation: 1486

Logging MQ Messages

I want to log messages that come into MQ Queue to database/file or another logging queue and I can not modify existing code. Are there any methods to implement some kind of message logging utility that will act like HTTP sniffer? Or maybe MQ have some built-in finctionality to log messages?

Thanks in advance for your ansers.

Upvotes: 2

Views: 3411

Answers (3)

Aliti
Aliti

Reputation: 2095

Here are commands of @Shashi's comment:

DEFINE QLOCAL ('RECV.Q')
DEFINE TOPIC('LOG.TO.DB') TOPICSTR('DBLOG')
DEFINE QALIAS('ALIAS.LOG.TO.DB') TARGET('LOG.TO.DB') TARGTYPE(TOPIC)
DEFINE QLOCAL('LOG.TO.DB.Q')
DEFINE SUB('SUB.FOR.RECV.Q') DEST('RECV.Q') TOPICOBJ('LOG.TO.DB')
DEFINE SUB('SUB.FOR.LOG.TO.DABASE') DEST('LOG.TO.DB.Q') TOPICOBJ('LOG.TO.DB')

Upvotes: 2

Shashi
Shashi

Reputation: 15273

I think this is possible by creating ALIAS QUEUE that points to a topic.

Assuming RECV.Q as the queue that your application currently receives messages from and processes.

1) First create a topic, say LOG.TO.DATABASE.
2) Then create an alias queue ALIAS.LOG.TO.DATABASE with Base object set to LOG.TO.DATABASE and set Base Type as Topic.
3) Then create a local queue LOG.TO.DATABASE.Q
4) Create a durable subscription, SUB.FOR.RECV.Q that points to RECV.Q as destination.
5) Create another durable subscription SUB.FOR.LOG.TO.DABASE that points to LOG.TO.DATABASE.Q as destination

Now the sender application need to put messages to ALIAS.LOG.TO.DATABASE. Since the alias queue actually points to topic, the messages gets published onto LOG.TO.DATABASE. To this topic we have two subscriptions registered, so both will get the same message. Your consumer application will continue to work as is whereas a new application can be written to process messages from other subscription.

Upvotes: 5

Roger
Roger

Reputation: 7456

Or you can use (free) open source project called Message Multiplexer (MMX) http://www.capitalware.biz/mmx_overview.html

If you need may queues to be logged/audited then you may want to look at MQ Auditor (it is a commercial product): http://www.capitalware.biz/mqa_overview.html

Upvotes: 1

Related Questions