anyone here actually using an event gateway in luc...
# cfml-general
d
anyone here actually using an event gateway in lucee (5.3.9.141) and it works? i've used them in ACF before and it was easy, but lucee does not seem to ever use my cfc (i am not using a custom listener)
b
@david.kreimer I've used them and written one. They work, but very differently than Adobe does EGs
What specific one are you trying to use?
d
the async gateway
i created a file in a folder off the webroot. called test.cfc and put the following into it
Copy code
component output="no" {
    this.logfile    = "coconuts.log";
    public void function onIncomingMessage(struct CFEVENT={}){
        log text="CFMLAsyncListener onIncomingMessage - Event Listener" file=this.logfile;
        log text="CFMLAsyncListener boop boop - Event Listener" file=this.logfile;
        writedump(var="CFMLAsyncListener boop potato - Event Listener",output=this.logfile);
    }
    private void function _handleError(required any catchData, string functionName='unknown'){
        log text="CFMLAsyncListener_handleError - Event Listener" file=this.logfile;
       //writeDump(var="#catchData#",output="console");
    }
}
then i set up the async gateway to use what is essentially /app/test.cfc
i see 3 entries in the in the gateway.log but i dont think it ever calls my onIncomingMessage function in test.cfc
this is from asyngateway.log NOT coconuts.log
there is no coconuts.log
the listener component for the async gateway is lucee.extension.gateway.AsynchronousEventsListener
Copy code
./WEB-INF/lucee-server/context/WEB-INF/lucee/components/lucee/extension/gateway/AsynchronousEvents.cfc
./WEB-INF/lucee-server/context/WEB-INF/lucee/components/lucee/extension/gateway/AsynchronousEventsListener.cfc
./WEB-INF/lucee-web/components/lucee/extension/gateway/AsynchronousEvents.cfc
./WEB-INF/lucee-web/components/lucee/extension/gateway/AsynchronousEventsListener.cfc
i've looked at all 4 of those files, even modified the one in lucee-web. that one specifically because i'm setting the event gateway up in the web context (not server)
b
Honestly, I never really understood the point of the async gateway
d
i commented this line out because i saw a notification about it in the server log
b
Just use cfthread, lol
You can't use the example, it's teribly broken
the empty try block is where the logic is supposed to be
it just sits and churns away your CPU
I reported it about a year ago, but it was "addressed in 6.0" šŸ˜•
d
.....
i should have read the code more closely
it literally never calls sendmessage
b
yup
It's like someone started to make the example and then got distracted
Or redacted some of the code
But seriously though, just use cfthread
d
the docs for event gateways are not great either
b
It does the same thing, lol
d
well, the event gateway is supposed to use a message queue on the backend (at least in ACF). i dont think it does that in lucee, though i was going to integrate an actual message queue when i have time
kafka or sqs or something else
i was under the impression event gateways have their own thread pool (they do in ACF) but i saw no indication of that in lucee
b
Basically, in Adobe, it has • all the mechanism to start/stop/restart the daemon threads • an entire internal queuing mechanism for routing messages and throttling how many execute But in Lucee, the gateway is responsible for running any sort of daemon thread(s) and there is no queue
šŸ‘ 1
When the start method is run, it's up to your code to either start a thread or more than one thread that you want to process things
I did this for an ActiveMQ gateway I wrote for a client, but it was a butt ton of work to manage manually and CFML proper has no thread pooling mechanism
d
aha. i cant tell a junior dev to do all that. i guess we'll abandon the gateway for now
b
Java does, but that creates a whole new set of issues related to losing your page context
d
does v6 implement a queue?
b
Not that I'm aware
d
im ok with not having any variables scoped/request vars/cgi/etc
b
Adobe has an ulterior motive for the queue. That way they can charge you extra to have more than one thread on Enterprise šŸ˜‰
d
no doubt. we have a ton of enterprise licenses (i think it's just one now, actually, a large one) for ACF
thanks for your help as always @bdw429s. i didnt find that issue on the bug tracker when i searched (google). thanks for submitting that report as well
šŸ‘ 1
e
Actually, the gateway in lucee works, but as @bdw429s suggested, completely throw your AFC code out. Its not as hard as you are making it, an example that shows gateway working in Lucee is here:

https://www.youtube.com/watch?v=rvB7PcNylVYā–¾