ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Activating MQ trigger through JMS, is there a way?

Post new topic  Reply to topic
 Activating MQ trigger through JMS, is there a way? « View previous topic :: View next topic » 
Author Message
peteles
PostPosted: Wed Aug 30, 2006 11:36 am    Post subject: Activating MQ trigger through JMS, is there a way? Reply with quote

Newbie

Joined: 30 Aug 2006
Posts: 3

Hello,

I'm looking to do this MQ Java API based command:

mQueueSet.setTriggerControl(MQC.MQTC_ON);

but via JMS:


QueueConnectionFactory qcf = ServiceLocator.getInstance().getQueueConnectionFactory(QCF_JNDI);
Queue queue = ServiceLocator.getInstance().getQueue(QUEUE_JOURNALISATION);

((com.ibm.mq.jms.MQQueue) queue).setTriggetControl(ON);
(something like that)



This is to avoid to connect twice to this queue: one connection with JMS, and another connection with the MQ API just to activate the trigger.

Thanks!
Back to top
View user's profile Send private message
wschutz
PostPosted: Wed Aug 30, 2006 2:33 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Generally speaking, JMS doesn't allow all the "control" over MQ objects that you have with the base java classes...

so can you explain exactly what the problem is that you're trying to solve and why you think you need to solve it by turning triggering ON?
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
peteles
PostPosted: Thu Aug 31, 2006 5:36 am    Post subject: Reply with quote

Newbie

Joined: 30 Aug 2006
Posts: 3

Here's what we do:

We got an MDB listening on a INITQueue in which the trigger message is posted. The trigger message is triggered on queue depth event (100 messages) on the logging queue.

When the logging queue gets at 100 messages, MQ put a trigger message and the MDB starts and then connect on the logging queue to store the messages inside the database, that's all.

So, to put back the trigger at ON at the end of the 100 consumed messages, we use MQ Java API. But with this, we have the reconnect an other time to the logging queue to put back on the trigger. I'd like to avoid this second connexion.


wschutz wrote:
Generally speaking, JMS doesn't allow all the "control" over MQ objects that you have with the base java classes...

so can you explain exactly what the problem is that you're trying to solve and why you think you need to solve it by turning triggering ON?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 31, 2006 5:43 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

What insane business requirement has you waiting for 100 messages before you do a database insert for a message log? You're having to jump through a lot of hoops to "batch" something that should be a transactional process.

Worrying about another question at this point is probably a false economy.

But what you could do is build a PCF message, and send that over the JMS connection.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
peteles
PostPosted: Thu Aug 31, 2006 6:08 am    Post subject: Reply with quote

Newbie

Joined: 30 Aug 2006
Posts: 3

100 is an example.

What is a PCF message?

jefflowrey wrote:
What insane business requirement has you waiting for 100 messages before you do a database insert for a message log? You're having to jump through a lot of hoops to "batch" something that should be a transactional process.

Worrying about another question at this point is probably a false economy.

But what you could do is build a PCF message, and send that over the JMS connection.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 31, 2006 6:30 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

peteles wrote:
100 is an example.


As far as I'm concerned, having to wait for 2 messages is probably thinking about the problem wrong. What reason is there for having a message sit on a queue for some period of time?

peteles wrote:
What is a PCF message?

Programmable Command Format.

See the support pack MS0B.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
julian
PostPosted: Wed Mar 12, 2014 8:15 pm    Post subject: Activating triggering for a given queue Reply with quote

Newbie

Joined: 12 Mar 2014
Posts: 2

WE have a similar problem recently and sending a PCFMessage to the admin queue was how we solved it.
Back to top
View user's profile Send private message
julian
PostPosted: Wed Mar 12, 2014 8:17 pm    Post subject: Our solution for activating triggering on a MQ queue Reply with quote

Newbie

Joined: 12 Mar 2014
Posts: 2

Code:

/**
 * Utility class to connect to a given queue manager admin queue and
 * switch on the triggering for a given MQ queue.
 */
public class MQQueueTriggeringActivator {
    private static final String MQ_TRANSPORT = "MQSeries";
    private static final int THIRTY_SECONDS = 30;
    private static Logger logger = Logger.getLogger(MQQueueTriggeringActivator.class);

    private final MQQueueManager mqQueueManager;
    private final String qmName;

    public MQQueueTriggeringActivator(QueueManager queueManager) {
        qmName = queueManager.getName();
        String qmHost = queueManager.getHost();
        String qmChannel = queueManager.getChannel();
        int qmPort = queueManager.getPort();

        logger.debug(format("Creating trigger activator for %s queue manager", qmName));

        Properties properties = new Properties();
        properties.put("hostname", qmHost);
        properties.put("channel", qmChannel);
        properties.put("port", qmPort);
        properties.put("transport", MQ_TRANSPORT);

        MQEnvironment.hostname = qmHost;
        MQEnvironment.channel = qmChannel;
        MQEnvironment.port = qmPort;

        try {
            mqQueueManager = new MQQueueManager(qmName, properties);
            MQQueue adminQueue = mqQueueManager.accessQueue(mqQueueManager.getCommandInputQueueName(), 32);
            int i = adminQueue.getOpenInputCount();
            adminQueue.close();
            if (i == 0) {
                throw new RuntimeException("Could not access the admin queue for MQ Queue Manager " + qmName);
            }
        } catch (MQException e) {
            throw new RuntimeException("Could not access the admin queue for MQ Queue Manager " + qmName, e);
        }
    }

    public boolean activate(String queueName) throws JMSException {
        logger.debug(format("Activating triggering for %s queue on %s queue manager", queueName, qmName));
        PCFMessage pcfMessage = new PCFMessage(CMQCFC.MQCMD_CHANGE_Q);
        pcfMessage.addParameter(MQCFST.MQCA_Q_NAME, queueName);
        pcfMessage.addParameter(MQCFIN.MQIA_Q_TYPE, MQCFIN.MQQT_LOCAL);
        pcfMessage.addParameter(MQCFIN.MQIA_TRIGGER_CONTROL, MQCFIN.MQTC_ON);

        boolean triggerActivated;
        try {
            PCFMessageAgent agent = new PCFMessageAgent(mqQueueManager);
            agent.setWaitInterval(THIRTY_SECONDS);
            PCFMessage[] response = agent.send(pcfMessage);
            agent.disconnect();
            triggerActivated = response[0].getCompCode() == MQCFIN.MQCC_OK;
        } catch (Exception e) {
            throw newJMSException(e, queueName);
        }
        return triggerActivated;
    }

    private JMSException newJMSException(Exception e, String queueName) {
        JMSException exception =
                new JMSException(format("Could not reset the queue dept trigger for %s queue", queueName));
        exception.setLinkedException(e);
        return exception;
    }

}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Activating MQ trigger through JMS, is there a way?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.