Menyh
Menyh

Reputation: 717

Dynamic query as Inbound connections to MULE

I am trying to create an SQL query inbound connection to my Mule server but I want the query itself to be dynamic (meaning I want to add a value such as: SELECT * FROM SOME_TABLE WHERE TimeStamp > SomeDynamicVariable).

How would I go about creating such an inbound connection, considering that I want to poll the database every so often?

Upvotes: 3

Views: 1841

Answers (1)

David Dossot
David Dossot

Reputation: 33413

In Mule, what you want to achieve is called "requesting" (ie. consuming an endpoint with a custom expression) and is not handled with inbound endpoints.

To achieve your goal you need:

  • A global JDBC endpoint using a Mule expression for the timestamp value, for example like this:

    <jdbc:query key="myQuery" value="SELECT * FROM SOME_TABLE WHERE TimeStamp > #[payload]"/>
    
  • A Quartz inbound endpoint to generate an event containing in the payload the timestamp to be used in query,

  • A message enricher to request from the endpoint and set the resulting value in the current payload (target = #[payload]).

D.

Upvotes: 2

Related Questions