Six Stars

Setting a context selection in a deployed service

Using TOS for ESB, how to set a job context after a service was deployed into karaf?
Let's say I have a job with two contexts: Dev and Prod. Is there a parameter to set the context selection on a .cfg file for example?
Thanks in advance.
6 REPLIES
One Star

Re: Setting a context selection in a deployed service

I'm curious if it's possible too...!
Employee

Re: Setting a context selection in a deployed service

HI ,
yes, it is possible via a .cfg file to change the context of a Data Service.
By default the Data Service starts with the default context you defined in studio and you not have to do anything if this is ok, but if you like to switch the context you can create a .cfg file with the name of the Service (e.g. for the ESBDEMO Example project 'DemoService' the file name would be 'DemoService.cfg and it needs to be created in the /etc folder of the container. Within this file create one line 'context = test' in case you like to use the 'test' context and you can now replace 'test' with 'prod' or any other context name you have defined in the Studio for your Data Service. You need to either stop and start the Data Service related bundles or even a bit easier if you used a kar file just delete it from the deploy folder (so that the feature get automatically undeployed and copy it again after a few second to the folder ) Now the Service will startup with the context you specified.
HTH,
Dietmar
Six Stars

Re: Setting a context selection in a deployed service

Thank you Dietmar,
I've tried the steps bellow without success:
1. I've created a .cfg file with the name of the service eg.: ConsultaApolice.cfg
2. I've Put the string "context = Development" inside the .cfg file (I've a matching context on my job).
2. I've deleted the .kar file and deploy again after a few seconds.
The context didn't changed...
One Star

Re: Setting a context selection in a deployed service

Hi anselmopeixoto, try with the WS's name (in studio) you expose in Karaf (the entry point of your ws). It's works for me.
ex:
if your ws name is 'myWS' in your studio, try the .cfg file 'myWS.cfg' in the <runtime>/container/etc repository.
After it's work if you refresh your ws in Karaf. ( osgi:refresh <id of your bundle deployed> )
Xavier
Six Stars

Re: Setting a context selection in a deployed service

Thank you Xavier,
Actually I created again a .cfg file with the same name of my WS (i.e.: ConsultaApolice.cfg, as before) and misteriously it worked this time.
Best regards.
Anselmo
One Star

Re: Setting a context selection in a deployed service

I discover a limitation that can be very irritating: it appears that if you use special caracters in your WS name (in java specs) (but accepted in studio), karaf can't resolve the name of your .cfg file with your WS.
example: you have '-' in the name of your WS, like 'my-WSName'
if you try to pass 'my-WSName.cfg' with a context it doesn't work
but 'my_WSName' and 'my_WSName.cfg' works fine...
and there are no messages in Karaf's logs.
It's known by Talend Team?
Xavier