cancel
Showing results for 
Search instead for 
Did you mean: 

how to launch asynchronous/background task

former_member190457
Contributor
0 Kudos

Hi all,

I'd like to launch a background/asynchronous task performing some logic.

I know that JEE6 includes the @asynchronous annotation for EJB 3.1 methods, but it's not supported in the EJB 3.1 Lite spec implemented.

In addition, the usage of JMS is not possible since HANA Cloud does not implement it.

How can I launch an asynchronous task?

Thanks and regards

Vincenzo

Accepted Solutions (1)

Accepted Solutions (1)

former_member190457
Contributor
0 Kudos

hi Vlado,

do you know whether there's any update on this?

thanks, regards

Vincenzo

Vlado
Advisor
Advisor
0 Kudos

Hi Vincenzo,

Sorry, not yet. I've asked the colleagues to look at it. Will keep you posted with the findings.

Cheers,

--Vlado

Former Member
0 Kudos

Hello Vincenzo,

EJB timers worked before we updated the EJB container - with the newest sdk versions, EJB timers require new versions of some sdk components. Currently we are considering updating these in a backward compatible way.

We'll keep you up to date with the news around this topic.

Kind regards,

Katya

former_member190457
Contributor
0 Kudos

Hi Katya, thanks for your kind reply.

Is there any rough timeframe as to when Java EE timers will become available?

Thanks, regards

Vincenzo

Former Member
0 Kudos

We're currently evaluating the impart of the change - probably we'll have an approximate timeframe of EJB timers availability in two weeks. I'll update this thread when there's more info.

Kind regards,

Katya

Former Member
0 Kudos

Hi Vincenzo,

EJB timer functionality will be part of neo-javaee6-wp-sdk-2.31.11.

Kind regards,

Katya

former_member190457
Contributor
0 Kudos

Thanks a lot, I will consume this feature shortly and provide a feedback in case of problems.

NikiD
Employee
Employee
0 Kudos

We will post a link to the release notes containing the feature as the exact version may differ.

Nikolai

Answers (2)

Answers (2)

Vlado
Advisor
Advisor
0 Kudos

Hi Vincenzo,

You are correct - asynchronous features (timers, MDBs) are not part of EJB Lite, and JMS is not part of Java EE 6 Web Profile (btw, it's Java EE, not JEE).

But... there is good news - you can use EJB timers with the SDK 2.x (though not officially supported). Check this blog for the details:

HTH!

--Vlado

former_member190457
Contributor
0 Kudos

Hi Jan and Vlado,

thanks so much for your valuable ideas.

I understand the timer service is not official supported, though I appreciate it might most certainly work ok. Spring would certainly be a good choice, though adding an additional degree of complexity as it is a different framework.

I found out also that the Quartz API can provide good support in the matter of job scheduling.

A good blog is found here:  http://scn.sap.com/people/aleksandar.zlatkovski/blog/2013/02/22/scheduling-jobs-on-sap-netweaver-clo...

Do you have any experience on this library or any opinion on whether it might be better/worse than the proposed options?

Thanks so much for your kind attention

Regards

0 Kudos

Hi Vincenzo,

I'm using Quarz in a productive application on SAP HANA Cloud Platform by just following the exact blog post that you have referred to. It works perfectly for my use case to schedule a regular job to send some notification mails.

I haven't tried EJB timers though.

Best regards,

Vesselin

Vlado
Advisor
Advisor
0 Kudos

Well, Quartz is also a framework on itself, and it's specifically designed for job scheduling scenarios. I don't have that much experience with it as with EJB timers, basically it requires at least some integration efforts but also can support more complex scenarios. On the other hand, EJB timers work out of the box and are a good fit for most use cases.

So, if you don't need some very special features that are not available with the EJB timer service, I would recommend to go for EJB timers and see how it works for you. If you need more, you can always switch to Quartz

HTH!

--Vlado

jpenninkhof
Product and Topic Expert
Product and Topic Expert
0 Kudos

If you were planning to use spring for background tasks, you're in luck, because it also has it's own scheduler. The good news is that spring also supports Quartz as a plugin.

Quartz is a very nice lib/framework for scheduling jobs. I have used it quite often and never failed on me.

former_member190457
Contributor
0 Kudos

Hi Vlado,

thanks, that makes sense. I have a couple more questions on how to use the EJB timer for emulating a Thread. For instance:

  • how do you launch a timer to run immediately? Looking at the API, it should be something like "start in 1 second"?
  • how would you pass a parameter to the Timer instance before launching it? I guess one should specify a TimerConfig object from which the EJB could retrieve the necessary parameters, right?

Thanks so much, regards

Vincenzo

Vlado
Advisor
Advisor
0 Kudos

Sorry Vincenzo, I somehow missed your response.

Sure, you can use the TimerService.createTimer(long duration, java.io.Serializable info) method and pass 0 as duration. The info object can be any Serializable object, which you can then get from the Timer passed to the EJB @Timeout method.

HTH!

--Vlado

former_member190457
Contributor
0 Kudos

Hi Vlado,

after a bit of time, I'm following up on this topic in my project.

I have created a Stateless EJB with a Timeout annotated method.

When I deploy it within the lib folder of a WAR archive to the local HCP I get errors like:

Exception: class java.lang.NoClassDefFoundError: org/quartz/simpl/RAMJobStore: org/quartz/simpl/RAMJobStore

And I am not using Quartz, just the plain EJB @Timeout.

Is there anything I'm missing?

Thanks a lot

Regards

Vincenzo

Vlado
Advisor
Advisor
0 Kudos

Hi Vincenzo,

Yes, I reproduce it. This looks like an issue with the OpenEJB bundle - it uses some classes from Quartz but the corresponding packages are not imported in the Manifest. Let me try and clarify this with the colleagues responsible for the runtime container.

Cheers,

--Vlado

former_member190457
Contributor
0 Kudos

Thanks a lot Vlado for your support,

I'm eager to have the Timeout service fully working!

Regards

Vincenzo

jpenninkhof
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Vincenzo,

(Almost) the same annotation is also implemented in Spring. You may want to try that out.

More info can be found on this pretty elaborate blog (cough, cough):

Good luck!

- Jan