Alex, You can certainly use a queue and queue up the messages in a callback. Typically, the way this works is:
You create a method with an @OnScheduled annotation. In this method, you create a client object and start the client. Here you can provide a callback to the client, and have that callback add the incoming message to the queue. In the onTrigger method of your processor, you can call queue.poll(). If this returns null then you'd called context.yield() and return. This allows you to avoid using a lot of CPU resources when there's nothing to do. If a message is returned, then you would create a new FlowFile for it, write the contents of the message to the FlowFile, and then call session.commit(). After session.commit() has completed, you are now free to acknowledge the message (assuming that you are using Client Acknowledgment). The GetTwitter processor actually behaves fairly similarly to this. Does this help? Thanks -Mark > On Nov 5, 2015, at 9:49 AM, McCullough, Alex <[email protected]> > wrote: > > Hey There, > > This is a bit of a generic question, and I am not sure if this is the right > place to start but I am new to developing custom processors in Nifi but have > been trying to write an asynchronous message consumer to consume from IBM MQ. > > I have read all of the developer documentation and have been testing a > processor I built, but I think where I am struggling is conceptualizing > exactly how I should set this up within the framework and how the threading > within Nifi works exactly. > > Typically I am used to registering a listener and using the onMessage method > to add messages that are received to local queue to then be processed. What > would this look like within the Nifi framework? Are there any guiding > principals you can point me towards or any source code that may be doing > something somewhat similar? > > Sorry this is a pretty vague question and I’m sure there are many ways to > skin this particular cat, but hoping you can help point me generally down the > right path. > > Thanks a ton and please let me know if you want me to provide anymore detail! > > Thanks, > Alex > > ________________________________________________________ > > The information contained in this e-mail is confidential and/or proprietary > to Capital One and/or its affiliates and may only be used solely in > performance of work or services for Capital One. The information transmitted > herewith is intended only for use by the individual or entity to which it is > addressed. If the reader of this message is not the intended recipient, you > are hereby notified that any review, retransmission, dissemination, > distribution, copying or other use of, or taking of any action in reliance > upon this information is strictly prohibited. If you have received this > communication in error, please contact the sender and delete the material > from your computer.
