Camel route with a dynamic timer? - apache-camel

I need to repeatedly refresh a token based on its contained expiry value. Is there a way in camel to setup a route using a timer (or Quartz) to refresh the token then set the next date/time for the route to be triggered again?
Regards,
Matt

No the easiest way is likely just a timer/quartz and then use a filter to then only call the refresh token at that time you want. You can then use a shared bean to store the state of the next time which you can use in the filter to compute whether to trigger the filter or not.

Related

Can I get updates (DirSync Cookie) in Active Directory with paging?

I am using DirSync Control (Cookie) to get the latest changes using the below technique. Is it possible to get that result with pagination ?
https://learn.microsoft.com/en-us/windows/win32/ad/polling-for-changes-using-the-dirsync-control
Example: If 500 updates have happened, can i get updates from 1-50, or 51-100 (paging with skip) ?
The result returned is paginated. You need to put the cookie, returned from the previous response into the next request. However, from my experience the number of changes on every page may vary. You can set the upper border, but I would not recommend to rely on it. If you want to display/send changes in batches with predefined size additional processing should be done on the client side

Best way to refresh token every hour?

I am building a website with React and I have to send about 3 requests per every page, but first of all I have to get communication token that needs to be refreshed every hour by the way, and then use it as a base for all other requests.
I have a plan to get it as soon as App mounts and put it in state (redux, thunk) and use it in every component that subscribes to store and then put setInterval function in componentDidMount method too. Another thing that comes to my mind is to put it in local storage but that would be a bit complicated (I have to parse every time I get something from local storage).
class App extends React.Component {
componentDidMount() {
this.props.getToken()
setInterval (this.props.getToken, 5000)
}
This works pretty well, and switching between pages doesn't spoil anything, it works pretty good. Note that here 5000 miliseconds is just for trying out, I will put it to be 3500000. Is this OK or there is another way to do this? Thanks!
Your implementation is pretty fine although I'd make a few changes
Use local storage so you don't have to refetch your token if user refreshes the page (since it'll be lost from memory). Also you'll have same benefit when working with multiple tabs. You can easily create some LocalStorageService that does all parsing/stringify for you so you don't have to worry.
I'd suggest to move that logic to some kind of service where you'll control your token flow much easier - e.g. what happens if user logs out or somehow token becomes invalid? You'd have to get new token from other place than your App (since root componentDidMount will be called only once) and also you'd need to clear the current interval (on which you won't have reference with current implementation) to avoid multiple intervals.
Instead of intervals maybe you could even use setTimeout to avoid having multiple intervals in edge cases:
getToken() {
// do your logic
clearTimeout(this.tokenExpire);
this.tokenExpire = setTimeout(() => getToken(), 5000);
}
Overall your implementation is fine - it can only be improved for easier maintenance and you'll need to cover some edge cases (at least ones mentioned above).
Ideally your server should put tokens on secured sessions so they are not vulberable to XSS.
If there's no such an option. I'd suggest using axios. You configure it to check the tokens on each request or response and handle the tokens accordingly.

Dynamic interceptFrom()

The documentation for "intercepts" says:
The interceptSendToEndpoint is dynamic hence it will also trigger if a
dynamic URI is constructed that Camel was not aware of at startup
time.
The interceptFrom is not dynamic as it only intercepts input to
routes registered as routes in CamelContext.
Is there an idiomatic way to create something equivalent to a dynamic "from intercept"?
Stepping back, here is what I want to do: intercept every time a message is written to or read from a jms component, where the URI matches a certain wildcard pattern.
Then use something else than interceptFrom, such as event notifier where you can get a notification when sending/sent/received etc.
http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html
http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html

Make an asynchronous call from Oracle ADF

I have an af:outputText on my page.
Its value takes a long time to generate, so I don't want to generate when initially creating the page.
Instead, I'd like the page to make an asynchronous call back to the server once loaded, the return value will then populate the outputText.
What is the best way of achieving this in ADF?
... or you use an af:poll component that checks the available status of the queried data. If the data is available, you disable the poll (ensure you PPR the af:poll component then)
Frank
Here is a hare-brained idea that might work:
set your outputText's rendered property to false; This will cause its value expression not be evaluated while your page is being loaded.
On load of the page, fire a javascript AdfCustomEvent towards a server listener which will then toggle the rendered state and PPR the outputText.
A more complex but probably cleaner approach would be to look into ADS to lazy load the value somehow.
Active Data Service (ADS) is a good fit for this. See http://docs.oracle.com/cd/E15523_01/web.1111/b31974/adv_ads.htm
Also Lucas Jellema has a great example of using ADS at http://technology.amis.nl/2011/10/19/adf-faces-handle-task-in-background-process-and-show-real-time-progress-indicator-for-asynchronous-job-using-server-push-in-adf/
Use af:poll and set the partial trigger of af:OutputText to af:poll so that the OutputText will automatically get refreshed on the first poll.In the poll listener set the poll interval to -1 (disable it)

Adobe Flex Caching Array

My program fills an array with data from a facebook page feed but every time i go from one tab to another it wants to reload this data, is there any way i can cache this array so that it will not reload the information unless its changed?
This is exactly why your Views should not contain Service logic. Instead, your View should dispatch an event asking for the service call and your Controller (you do have one, right?) should catch that event and decide whether to act on it or not.
How do you know the data hasn't changed without reloading it?
Maybe what you need is to store the timestamp of the last service call, than measure the amount of time before executing the service call again.
Perhaps with a 5-minute timeout, if the user continuously changes tabs within 5-minutes from the last service call, the array persists previously loaded data.
After 5-minutes, if the user changes back to that tab the service call can fire, load data, than update the timestamp to prevent loading.

Resources