JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-4119

Make JmsMessageRequester support expressions in selector

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.1.2
  • Fix Version/s: 2.2
  • Component/s: Transport: JMS
  • Labels:
    None
  • User impact:
    Low
  • Affects Docs:
    Yes
  • Migration Impact:
    Hide
    JMS Selector Filter now support Mule expressions. However, they make sense for requestor only (e.g. the quartz example posted here or muleClient.request()). Then, the applicability is limited, as there is no message yet available at the time of resolution, so only those expressions not relying on message are parsed.
    Show
    JMS Selector Filter now support Mule expressions. However, they make sense for requestor only (e.g. the quartz example posted here or muleClient.request()). Then, the applicability is limited, as there is no message yet available at the time of resolution, so only those expressions not relying on message are parsed.
  • Similar Issues:
    None

Description

It would be really cool if the JmsMessageRequester could pass the selector string to the ExpressionEvaluatorManager for expression parsing.

This would open the door for dynamic message requesting through on-the-fly evaluated expressions. This would make less sense at JmsMessageReceiver level, where such a dynamic behavior is probably useless.

On the downside, it could create backwards compatibility issues if someone is using #[xxx] in an existing JMS selector used by a requester.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
Hide
Permalink
Andrew Perepelytsya added a comment - 22/Jan/09 02:00 PM

Hi David. The only problem with doing it is that expression manager will not have a message instance, and there's no way it could, as selector is set on the consumer at creation time, before it has a chance to consume anything and return a message.

This, however, may simply mean that you'll not be able to use evaluators relying on a message, but any other evaluator would still work. Is it in line with your expectations?

Show
Andrew Perepelytsya added a comment - 22/Jan/09 02:00 PM Hi David. The only problem with doing it is that expression manager will not have a message instance, and there's no way it could, as selector is set on the consumer at creation time, before it has a chance to consume anything and return a message. This, however, may simply mean that you'll not be able to use evaluators relying on a message, but any other evaluator would still work. Is it in line with your expectations?
Hide
Permalink
David Dossot added a comment - 22/Jan/09 03:29 PM

Absolutely in line.

As you said it, there is still a couple of expression evaluators that could provide some goodness (for ex, in my case, function:systime).

Show
David Dossot added a comment - 22/Jan/09 03:29 PM Absolutely in line. As you said it, there is still a couple of expression evaluators that could provide some goodness (for ex, in my case, function:systime).
Hide
Permalink
Andrew Perepelytsya added a comment - 22/Jan/09 03:41 PM

Could you please post a sample config on how you'd be using it? That would help in creating the test case.

Show
Andrew Perepelytsya added a comment - 22/Jan/09 03:41 PM Could you please post a sample config on how you'd be using it? That would help in creating the test case.
Hide
Permalink
David Dossot added a comment - 22/Jan/09 03:56 PM

Sure! Here you go:

<quartz:inbound-endpoint cronExpression="0/5 * * * * ?"
jobName="queuePoller">
<quartz:endpoint-polling-job>
<quartz:job-endpoint
address="jms://queue?selector=JMSTimestamp+${messageDelay}%3C%3D%23[function:systime]"
timeout="1000" />
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>

Show
David Dossot added a comment - 22/Jan/09 03:56 PM Sure! Here you go: <quartz:inbound-endpoint cronExpression="0/5 * * * * ?" jobName="queuePoller"> <quartz:endpoint-polling-job> <quartz:job-endpoint address="jms://queue?selector=JMSTimestamp+${messageDelay}%3C%3D%23[function:systime]" timeout="1000" /> </quartz:endpoint-polling-job> </quartz:inbound-endpoint>
Hide
Permalink
Andrew Perepelytsya added a comment - 22/Jan/09 04:02 PM

Ok, I see now. I'd recommend you instead use a jms-specific endpoint with a nested selector config element and then reference it in quartz job-endpoint. This way the URI escaping may be avoided.

Show
Andrew Perepelytsya added a comment - 22/Jan/09 04:02 PM Ok, I see now. I'd recommend you instead use a jms-specific endpoint with a nested selector config element and then reference it in quartz job-endpoint. This way the URI escaping may be avoided.
Hide
Permalink
David Dossot added a comment - 22/Jan/09 04:07 PM

In fact, this is what I did:

<jms:endpoint name="delayedQueue" queue="queue">
<jms:selector expression="JMSTimestamp+${messageDelay}<=#[function:systime]"/>
</jms:endpoint>

I just put everything together to post a shorter config snippet (for which it took me some time to figure out the HEX escaping LOL).

Show
David Dossot added a comment - 22/Jan/09 04:07 PM In fact, this is what I did: <jms:endpoint name="delayedQueue" queue="queue"> <jms:selector expression="JMSTimestamp+${messageDelay}<=#[function:systime]"/> </jms:endpoint> I just put everything together to post a shorter config snippet (for which it took me some time to figure out the HEX escaping LOL).
Hide
Permalink
David Dossot added a comment - 26/Jan/09 04:47 PM

I may have a better design for this behavior... I have done the following:

  • subclass JmsSelectorFilter:

@Override
public String getExpression() { return ExpressionEvaluatorManager.parse(super.getExpression(), null); }

  • declare this custom filter in the global JMS endpoint:

<jms:endpoint name="delayedQueue" queue="queue">
<custom-filter class="my.JmsExpressionSelectorFilter">
<spring:property name="expression" value="JMSTimestamp+${messageDelay}<=#[function:systime]" />
</custom-filter>
</jms:endpoint>

  • use a standard quartz:endpoint-polling-job

This is clean enough for me, I can live with this approach without any code change from your side. Consequently, you can close/wont fix this JIRA if you don't see any extra value in altering the existing dispatcher (which I think is good to leave as it is).

Show
David Dossot added a comment - 26/Jan/09 04:47 PM I may have a better design for this behavior... I have done the following:
  • subclass JmsSelectorFilter:
@Override public String getExpression() { return ExpressionEvaluatorManager.parse(super.getExpression(), null); }
  • declare this custom filter in the global JMS endpoint:
<jms:endpoint name="delayedQueue" queue="queue"> <custom-filter class="my.JmsExpressionSelectorFilter"> <spring:property name="expression" value="JMSTimestamp+${messageDelay}<=#[function:systime]" /> </custom-filter> </jms:endpoint>
  • use a standard quartz:endpoint-polling-job
This is clean enough for me, I can live with this approach without any code change from your side. Consequently, you can close/wont fix this JIRA if you don't see any extra value in altering the existing dispatcher (which I think is good to leave as it is).
Hide
Permalink
Andrew Perepelytsya added a comment - 27/Jan/09 03:27 PM

David,

There are some issues with the approach above:

  1. 2.2 has refactored the expression evaluator framework to drop statics
  2. if a filter always returns the processed value, there's no other way to get the original template

Anyway, I've committed a tentative change to support your scenario: http://fisheye.codehaus.org/changelog/mule/?cs=13848
The 2.2 snapshot deployment build is pending, you can grab it once it finishes (or just build from source): http://bamboo.mulesource.org/browse/MULE-MULE2XSNAPSHOTS/log

I'd appreciate if you tested this on your side and let us know if it fits the use case.

Show
Andrew Perepelytsya added a comment - 27/Jan/09 03:27 PM David, There are some issues with the approach above:
  1. 2.2 has refactored the expression evaluator framework to drop statics
  2. if a filter always returns the processed value, there's no other way to get the original template
Anyway, I've committed a tentative change to support your scenario: http://fisheye.codehaus.org/changelog/mule/?cs=13848 The 2.2 snapshot deployment build is pending, you can grab it once it finishes (or just build from source): http://bamboo.mulesource.org/browse/MULE-MULE2XSNAPSHOTS/log I'd appreciate if you tested this on your side and let us know if it fits the use case.
Hide
Permalink
Andrew Perepelytsya added a comment - 27/Jan/09 04:14 PM

One more: http://fisheye.codehaus.org/changelog/mule/?cs=13850

Show
Andrew Perepelytsya added a comment - 27/Jan/09 04:14 PM One more: http://fisheye.codehaus.org/changelog/mule/?cs=13850
Hide
Permalink
David Dossot added a comment - 27/Jan/09 05:39 PM

Andrew, thanks for warning me about the compromised future of my "solution".

I have tested the endpoint+selector approach with Mule 2.1.0-SNAP and it works perfectly well! Thanks!

D.

Show
David Dossot added a comment - 27/Jan/09 05:39 PM Andrew, thanks for warning me about the compromised future of my "solution". I have tested the endpoint+selector approach with Mule 2.1.0-SNAP and it works perfectly well! Thanks! D.
Hide
Permalink
Andrew Perepelytsya added a comment - 27/Jan/09 07:21 PM

Wondering how would I ever reliably test something like this (timing...). Closing as fixed

Show
Andrew Perepelytsya added a comment - 27/Jan/09 07:21 PM Wondering how would I ever reliably test something like this (timing...). Closing as fixed

People

  • Assignee:
    Andrew Perepelytsya
    Reporter:
    David Dossot
Vote (0)
Watch (0)

Dates

  • Created:
    22/Jan/09 01:50 PM
    Updated:
    27/Jan/09 07:21 PM
    Resolved:
    27/Jan/09 07:21 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.