WebSphere MQ定制:通过MQ Exits插入延迟的可行性咨询
Using MQ Exits to Implement Message Delays in WebSphere MQ (Instead of Sleep() Programs)
Absolutely! You can ditch that custom Java program with sleep() calls and use MQ Exits to handle message delays directly within WebSphere MQ—no need to write separate client code that connects to the queue manager. This is actually a perfect use case for MQ Exits, as it integrates the delay logic right into MQ's message flow instead of relying on external applications.
Which MQ Exit Type Should You Use?
You’ll want to work with Message Exits, specifically tailored to your scenario:
- Put Message Exit: Triggers when an application puts a message to a queue. You can use this to intercept messages that need delay, modify their properties, or route them appropriately.
- Forward Exit: If you’re dealing with message transfers between queues (like cluster forwarding or channel-triggered moves), this exit fires before the message is forwarded, making it ideal for inserting delays during queue-to-queue transfers.
Core Approach for Delays (Don’t Use Sleep() in Exits!)
Never call sleep() directly in an MQ Exit—it will block MQ’s worker threads and cripple performance. Instead, use MQ’s built-in capabilities to handle delays asynchronously:
- Route to a Delay Queue: In your Exit, identify messages that need delay (via custom message properties, header tags, or content). Route these messages to a dedicated delay queue instead of the target business queue.
- Schedule Message Forwarding: Use MQ’s native scheduling features (like the Schedule Manager introduced in MQ 9.1) or configure trigger rules to automatically forward messages from the delay queue to the target queue after the specified delay period.
- This method keeps MQ running efficiently, avoids thread blocking, and is far more reliable than client-side
sleep()calls.
Why MQ Exits Are Better Than Your Sleep() Program
- No Extra Client Code: Exits run directly within the queue manager’s process—no need to handle connections, authentication, or client-side error handling.
- Centralized Logic: All delay handling is managed in one place, so you don’t have to add delay logic to every application that puts messages.
- Better Performance: Eliminates the overhead of client-side threads sitting idle during
sleep()and reduces the risk of failures if your custom Java program crashes.
Key Notes to Keep in Mind
- Exit Development: MQ Exits are typically written in C or COBOL, but Java Exits are also supported (you’ll need to follow MQ’s Exit interface specifications).
- Avoid Blocking Operations: As mentioned, never put blocking calls like
sleep()in an Exit—stick to asynchronous routing and scheduling. - Test Thoroughly: Always validate your Exit logic in a test environment before deploying to production to ensure it doesn’t disrupt normal message flow.
内容的提问来源于stack exchange,提问作者spakendralo man
相关产品推荐
相关产品推荐

