Event-driven architecture (EDA) Coldbox Application?

Hi all,

We have a Coldbox monolithic application and we have started introducing Module to better organize the models and views together. As the app grows larger, we are thinking of introducing an EDA approach for communication between the bounded contexts. The way to implement EDA in coldbox would be using announceInterception() to pub & customInterceptionPoints with interceptor to sub?

What if we decide to migrate the bounded context into another CF server? So I just need to change the interceptor to start firing remote service calls, right?

If we want to enhance to reliability EDA with guarantee delivery and such, would introducing a MOM like ActiveMQ be a way to go? Anyone tried using a MOM for this and how well has it work with ColdBox or ColdFusion/Railo in general? Is CF event gateway the only way to talk to MOM? Are there any new MOM out there that can work solely on RESTful API calls?

Thank you,

Henry

​i’ve done something kinda like this via http://pusher.com/ but its not a pub/sub system. its more of a push if you’re online receive and deal otherwise ignore system.​ but i’ve had good luck with http://aws.amazon.com/sqs/

i like using an external service like amazon rather than an internal system like ActiveMQ or RabbitMQ mainly b/c i can’t depend on a service being 100% up whereas sqs is rock solid.

Wonderful. Are you @jeremydeyoung?

Would you please share your experience with doing CF with SQS? Did you use SQS with ColdBox?

Thanks,
Henry

yes, my primary twitter handle is @nextstepguru however i never really get on any more. i pretty much signed off all social networks haha but i’m happy to help!

yes i did use sqs with coldbox.

my basic goal was to throw up a message into a queue which consisted of a small json struct. something like {‘function’:‘coldbox-module:handler.action’,data:{}}

and i would have a queue automated tasks that would pull down randomly the message, throw it against the module/handle/action with data into the prc.

and my queue function would continuously poll the sqs server for 55 seconds then sleep until the next cron job hit.

i did run into trouble with multiple servers grabbing the same message sometimes.

you could take the same concept and add more data to a queue or create multiple queues for different actions/functions within SQS.

i know its not exactly what you’re trying to accomplish but it might be a start.

Interesting! Did you use cfscheduler to do long-polling with SQS?

I am now leaning towards RabbitMQ for performance and ease of use in case the stakeholders are not comfortable with sending sensitive data over to Amazon. Seems like I will need to write my own event gateway to talk to RabbitMQ based on their Java client. However, I’m using CF standard so performance will still sucks (single thread for event gateway) unless I go for Railo or CF Enterprise.

Anyhow, rolling out a MOM solution will be some time down the road. I just want to get EDA architecture going with ColdBox first. Did you make use of announceInterception() & custom inteceptor with customInterceptionPoints?

Henry

well i’m not a fan of acf - i use railo. also cfscheduler has never been reliable so i use cron.

as far as rabbitmq use something like this https://gist.github.com/mplacona/3194899

loads a jar - you could store it in an application var and push data to and from the object in a thread.

it should be very fast and memory/resources shouldn’t be a problem or at least it wasn’t in my experience.

as far as customInterceptionPoints - i use hundreds of them. i’m a huge fan of pusher.com as i can accomplish both javascript integration along with server based integration thru websockets. however its a use or lose it system. but it works very well and its been very scalable.

to put it differently. i have two servers for my website. another server that runs tasks. and the client side system. i created a small pusher plugin that i’m able to thread and throw data at it. i listen via a small app on my server that notifies cf of inbound websocket subscriptions and the jquery client is also monitoring. if the client, the two web servers or the tasks server changes lets say the order table, all are notified of the change in near real-time. the hardest thing to work out was getting the field naming convention on the client side to match correctly with a record in the database.

with saying all that, i’m able to push changes from jquery ajax to the server and announce the changes back via the customInterceptionPoint.

i also use the same concept for various other interception points. it works perfectly as long as no one modifies my database directly which only happens by me.

does that make sense? i’m probably sharing too much and no one else cares so feel free to message me directly so we don’t muddy up the coldbox group.

Henry,

I have used RabbitMQ with huge success. Especially since it support AMQP protocol. I have here a messaging polyglot repository: https://github.com/lmajano/messaging-polyglot

I basically use ACF10+ and Railo 4.1+ to talk to RabbitMQ with no need for event gateways. I leverage dynamic proxies to create runnable threads and also listeners. The samples are simple but powerful. Also, I have the code in Java, ColdFusion, Groovy, Python, and Node. So you can see how all technologies can talk to each other no matter the language.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

well there ya go! haha i probably took what you did luis back in the day and used it in my a while back! very good to know all the options!

signature0.jpg

Luis,

Cool, can you tell me more about “dynamic proxies to create runnable threads”? What is that?

Does this sort of bypass limitation of CF standard? Wow, nice. :slight_smile:

Does my plan of implementing EDA on ColdBox sound right to you? And switch interceptor when it’s time to move to RabbitMQ?

Thanks
Henry

signature0.jpg

Dynamic proxies allows you to create threads that can live forever via Java or act like deamons. You can see the consumer samples for that. I would still leverage interceptors for the events, but then have a MQ interceptor that can rely the message to a broker.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

signature0.jpg

I just read the code carefully. Your code creates a ConsumerTask (w/ blocking while loop) that implements Runnable and then you created a new Java thread to run the task. Right?

Interesting. Why did you pick Java thread over cfthread? or event gateway?

Henry

signature0.jpg

signature0.jpg

Because cfthreads expire on timeout. I needed something, a task, that could run until I stopped it.

Also, I wanted a solution that was cross-engine, both for ACF and Railo.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

signature0.jpg

signature0.jpg

Luis,

On paper it seems cfthread can run without timeout, did you try and it did not work? Actually I’m not sure if cfthread has any benefit other than there is a limit of 10 for CF standard.

I have an idea, would it be even better to use Java7 ThreadPool to invoke some sort of onMessageReceived() on a listener CFC concurrentlly? Basically implement our own enterprisey event gateway-like thing?

fyi Railo seems to have primitive event gateway support: https://github.com/getrailo/railo/wiki/Event-Gateways

Henry

signature0.jpg

signature0.jpg

signature0.jpg

Well, I really wanted to use the dynamic proxy to create a task-like runner. That’s why. Also, this allowed me to avoid any issues cross-engine.

You can as well (java thread pool), also using the java concurrency framework for tasks as well. Railo supports event gateways written in CFC’s, which is much better than writing them in Java (adobe cf), which is complicated.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

signature0.jpg

signature0.jpg

signature0.jpg