This means there is a bug in Synapse. In servlet transport based products, there is a Tomcat valve called CarbonContextCreatorValve, which ensures that the correct ThreadLocal context. But we don't have such a concept in PTT/NHTTP. What we should do is, perhaps, have an Axis2 handler that will set the correct ThreadLocal CC if it is not yet available. Debug the code that creates CC & see how/where it is called.
Azeez On Fri, May 17, 2013 at 11:47 AM, Sanjeewa Malalgoda <[email protected]>wrote: > Hi All, > If i send request to API deployed in synapse(in tenants space) and try to > get carbon context inside invoke method of handler i'm getting unexpected > result. See following code. Ideally this should returns tenant id of > service deployed tenant. API url is > http://10.200.3.87:8280/t/vvv.vvv/aaa/1.0.0 (tenant vvv.vvv's tenant id > is 1). WDYT? Where should we fix it? > > public class MyHandler extends AbstractHandler implements Handler { > > public InvocationResponse invoke(MessageContext messageContext) throws > AxisFault { > > PrivilegedCarbonContext carbonContext = > > PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); > /*/returns > -1 as tenant ID while actual tenant id is 1* > > PrivilegedCarbonContext carbonContext = > > PrivilegedCarbonContext.getCurrentContext(messageContext).getTenantId(); / > */returns -1234 as tenant ID **while actual tenant id is 1* > } > > > Thanks, > Sanjeewa, > -- > *Sanjeewa Malalgoda* > WSO2 Inc. > Mobile : +14084122175 | +94713068779 > > <http://sanjeewamalalgoda.blogspot.com/>blog > :http://sanjeewamalalgoda.blogspot.com/<http://sanjeewamalalgoda.blogspot.com/> > -- *Afkham Azeez* Director of Architecture; WSO2, Inc.; http://wso2.com Member; Apache Software Foundation; http://www.apache.org/ * <http://www.apache.org/>** email: **[email protected]* <[email protected]>* cell: +94 77 3320919 blog: **http://blog.afkham.org* <http://blog.afkham.org>* twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> * linked-in: **http://lk.linkedin.com/in/afkhamazeez* * * *Lean . Enterprise . Middleware*
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
