In our project, we use ProgramStart to implement cron jobs. The executions will always be carried on by the SYSTEM user using only one ISession(id = 0).

The problem is, we heavily store plenty of Context Information (authentication token, user-session-specific data, etc) into ISession.setAttribute(). It works well on normal situation with logged-in Ivy user. However, because in background jobs, there is only one session, each execution will interfere with each others, trying to set and get the Context Information.

In addition, this happens the same with Signals since execution of those also delegated to SYSTEM.

I've tried to call ivy.session.login() but it threw exception since Axon.ivy refuse to allow logging out of SYSTEM user.

My question is: Is there any possible way to switch from SYSTEM sessions to regular normal user's session?

Thanks

asked 27.05.2016 at 07:54

Genzer%20Hawker's gravatar image

Genzer Hawker
(suspended)
accept rate: 66%


In a ProgramStart you can program which Session should be used to execute the process in the EventBean. The method fireProcessStartEventRequest of the IProcessStartEventBeanRuntime interface takes as first parameter an ISession. The process will be executed in the context of this session. Most EventBean implementors simply give a null value for this Session. In this case the process is executed in the context of the SYSTEM session. To use another session do as follows:

ISession session = runtime.createSession();
try
{
  runtime.fireProcessStartEventRequest(session, ...);
}
finally
{
  runtime.destroySession(session);
}

The method createSession will create an annonymous session. There is also another createSession method that takes two arguments so that you can specify a user and password to create a session with a user. Don't forget to destroy the session otherwise you have a session leak.

For Signals there is no such solution available yet.

link

answered 27.05.2016 at 08:56

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Oooh, I didn't know about this. Guess I need to read more the API then. Will there be support for such use case in Signals? Thanks!

(27.05.2016 at 10:07) Genzer Hawker Genzer%20Hawker's gravatar image

It's not planned for Signals yet. If there is a concrete common use case we can provide support for it in a future version.

(27.05.2016 at 10:11) Reto Weiss ♦♦ Reto%20Weiss's gravatar image

As of now, we don't have any. But it could be the case that we will introduce an on-demand feature to trigger the same background job. A Signal would be broadcasted to run the process in additional to the existing EventBean.

(27.05.2016 at 13:16) Genzer Hawker Genzer%20Hawker's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×14
×9
×1
×1

Asked: 27.05.2016 at 07:54

Seen: 3,307 times

Last updated: 20.06.2018 at 10:56