Lucee and ActiveMQ


#1

I need to integrate a Web application deployed on Lucee 4.5 with ActiveMQ
message broker. It should be able to both produce and consume messages,
using ActiveMQ’s queues.
I’m guessing one of the options would be to use Event Gateways, however in
Lucee Web Admin I can only add “Directory Watcher”, “Mail Watcher” and
“Task Gateway”, no “JMS Gateway” or similar.

What would be the most robust approach to this subject? Could you point me
to any blog entries, tutorials or other examples? I’d appreciate your
comments.


#2

I have something I threw together a few months ago just to see if I could
do it (I could). While it wasn’t specifically structured around ActiveMQ,
it was using Amazon SQS, but I imagine it would be easy enough to implement.

Basically I create a long running thread in the background on the server
that polls for messages every 15 seconds.

https://kisdigital.wordpress.com/2016/07/18/creating-a-background-process-in-lucee/

The queue process actually communicates with the AWS service through
another CFC:

https://gist.github.com/robertz/cfd7973e3700e44fe0554d98be1fb15e

HTH


#3

Robert,

Thank you for your response and code examples. This is an interesting
approach. Was your decision about using cfthread instead of gateways caused
by any particular issues with the latter, or just out of curiosity about
cfthread?

I’ve read that long running threads are not recommended on busy
Web/application servers, although I think this particular post was about
PHP. We were using cfthread back in CF8 days, but it didn’t behave well so
we dropped the idea.

Could you share how does this long running process behave on your server?
How do you monitor/control it? Doesn’t it hang up/freeze/quit?


#4

When I was originally trying to implement this code, I was trying to
implement it as an event gateway on ACF. While that worked fine on ACF, as
you initially pointed out, event gateways in Lucee are quite a cut and
dried as they are on ACF. Also, a buddy had asked me why I decided to go
with an event gateway when it could have been refactored to a cfthread. The
event gateway code was introduced way before cfthread was an option, so
respecting his opinion, I decided to go that route.

As far as impact of running the thread on busy application servers, I
haven’t run this implementation on any server with any amount of load.
Mostly this was a PoC application just to see if I could implement it; I am
afraid I don’t have any hard data on how it would behave in a production
environment.


#5

Hi Jacek,

I’m also using queues accessed with JMS through Event Gateways. The code is
available here:

Jean-Bernard


#6

Hi Jean-Bernard,

Thought I’d give your extension a try, but using the upload downloaded
extension function in Lucee 5.x I get an error: Only .lex extensions are
allowed.
I’m not sure if this is an error on Lucee’s behalf or if they
have changed their upload policies, because it clearly states that you
should upload a ZIP-file, not a LEX-fle. Any ideas? I’ll try the manual
install as well and tell how that went. Really need Active MQ for a current
ACF-webapp to be ported to Lucee.

Sebastiaan


#7

@jbvanzuylen do you have any updates on this? Ever tried to install the extension in Lucee? Would love to hear if this can be used in Lucee to mimic a ACF eventgateway.


#8

OK, have installed this manually and see the two new options appear in the Web admin > Services > Event gateway screen. But when I have created a gateway nothing happens - at least, the screen stays empty of running or available / created gateways. In the error log of Lucee I see this:

"ERROR","http-nio-8888-exec-5","01/03/2018","16:48:41","",";"
"ERROR","http-nio-8888-exec-7","01/03/2018","16:48:43","",";"
"ERROR","http-nio-8888-exec-10","01/03/2018","16:49:21","",";"
"ERROR","http-nio-8888-exec-2","01/03/2018","16:49:31","",";"
"ERROR","http-nio-8888-exec-7","01/03/2018","16:49:43","",";"
"ERROR","http-nio-8888-exec-10","01/03/2018","16:51:36","",";"
"ERROR","http-nio-8888-exec-3","01/03/2018","16:52:02","",";"
"ERROR","http-nio-8888-exec-5","01/03/2018","16:52:03","",";"
"ERROR","http-nio-8888-exec-7","01/03/2018","16:52:04","",";"
"ERROR","http-nio-8888-exec-9","01/03/2018","16:52:05","",";"
"ERROR","http-nio-8888-exec-1","01/03/2018","16:52:07","",";"

That’s an ERROR for everytime I have clicked on the link Event gateway under Services. So should I report this as an error to Lucee or is this a knows error? @modius do you possibly know?
I’m on latest Lucee version: 5.2.5.20.


#9

I get the same errors, I haven’t been able to track it down yet.


#10

I thought it was just me :wink:


#11

It’s been a while since I’ve worked on an Event Gateway project. If you can put together a small test case that demonstrates the issue I can certainly help to escalate the problem to the Lucee development team.


#12

@modius thnx, I will. It is quite simple actually - just try and create a gateway of some sort, fill in all the mandatory fields and click save. You’re returned to the initial Event gateways screen with nothing to show for what you just created.
I do not know how I can ask Lucee for all running gateways if I do not know the name of the gateway. Maybe then I can see if creating the gateway at all has worked and if the error comes from that end.
Trying to stop a gateway via the CFADMIN-tag (or admin in cfscript) does probably work, but it gives no feedback if this has worked or not if I try to fire it on a gateway ID I know I have created.


#13

OK, have given up this endeavour for now - I have a CFML gateway working now and do not need the ActiveMQ gateway yet. Will describe my solution for a simple working CFML gateway in another thread:

Getting the external Active MQ gateway working might not be necessary if we combine a certain set of application parts - then we can make use of the CFML gateway I have gotten to work now. I might revisit this thread if I need the Active MQ gateway to work or get it working myself based on my CFML gateway solution combined with the solution of @jbvanzuylen. Hope he can chime in sometime :wink: