After go through some guides about Mule, I have a question about the component, as it is said in mule documentation,
A simple POJO (Plain Old Java Object) component that will be invoked
by Mule when a message is received. The class or object instance to be
used can be specified using a child object factory element, or via the
'class' attribute. If the 'class' attribute is used, an object
factory cannot be configured as well. Using the 'class' attribute is
equivilant to using the propotype object factory ('prototype-object'
child element).
in this documentation just said the component will be invoked by Mule when a message is received, but a problem is Mule how to know how many methods the component have, and which method should be invoked? or there must one method in the component and no matter the method name? and also mule how to deal with the parameters the method have?
Alternatively, you can use:
<invoke object-ref="..." method="..." methodArguments="..." />
which is way more convenient than configuring entry point resolvers.
yes, I got the answer, the answer is using mule entry point
Related
I am trying to access the _clienName from the invocation properties. I tried the below one, but doesnt help. any thoughts ? Is it really possible to access invocation property in a mule flow ?
#[message.invocationProperties['_clientName']]
Message properties:
INVOCATION scoped properties:
__httpEvent=HttpEvent #188...9{apiName=.....95574017,something=99034}
_clientId=680.....81d97344
_clientName=abcd-app
INBOUND scoped properties:
Invocation Properties can be accessed via flowVars: #[flowVars['_clientName']] or #[flowVars._clientName]
Post Mule EE 3.4 there has been a naming change on all the invocation property as FlowVariables . Even now the invocation properties will work if you try using #[flowVars.name] . In the Message properties transformer you have option to set only as invocation properties but it can be accessed as flowVars in rest of the flow.
In mule invocation scoped properties are nothing but flowVars. So you can access them by using the following mule expression
#[flowVars.'_clientName']
in the above expression no need to wrap the _clientName in square brackets, just quote them as I did.
FYI
Session scoped properties are nothing but sessionVars. So you can access them by using #[sessionVars.'_clientName'].
Though you have not asked about session scoped properties, I have answered it because by reading your question I came to know that you are asking the question by seeing the logs in the console caused by the Logger Component of Mule.
The logger, not only logs Invocation scoped properties but also session scoped properties as well. So I guess you might get a question in your mind about what are Session scoped properties, so answered it.
I have a properties file shared on several apps. To access this properties into one app, I use this tag:
<context:property-placeholder location="classpath:br/com/empresa/configuracao/mule-apps.properties"/>
On several Mule components, like database attributes connections, I use the following expression to access the properties, p.e.: ${db.user}. It works!
But on Java Transformer, how I access the properties?
I tried the following instructions, but returned null:
System.getProperty("db.user");
message.getInboundProperty("db.user");
message.getOutboundProperty("db.user");
message.getInvocationProperty("db.user");
Is there a way to access properties into Mule Java Transformer?
This question has been answered for components here: How to get property from context property placeholder tag inside custom java component The exact same logic applies to transformers.
Use property injection:
<custom-transformer class="org.myCompany.CustomTransformer">
<property name="dbUser" value="${db.user}" />
</custom-transformer>
Don't forget to add setDbUser on your custom component!
You could use the old way of retrieving a property:
#Value("${db.user")
private String dbUser;
I am not able to figure out the method in which I can use the service.method attribute in Moqui. Is this similar to that of service.invoke attribute in OFBIz which allows me to call the method form the file specified in the location.
I was not able to find any examples related to this anywhere in the code.
The annotation in the XSD for the service.#method attribute says: "The method within the location, if applicable to the service type."
To expand on that, for Java classes this is the method within the class. For Groovy scripts you can call a method in the script (or Groovy class) instead of running the top-level of the script.
I have the following bindings declared
Bind<IDataSource>().To<DataSourceOne>();
Bind<ISettings>().To<DataSourceSettings>
.WhenInjectedInto<DataSourceOne>();
Bind<ISettings>().To<Settings>();
now I call
Kernel.Get<IDataSourc>();
Ninject correctly injects a DataSourceSettings, but I need to pass a constructor argument to Settings and DataSourceSettings based on data from a config file. so I've changed the IDataSouce binding as follows
Kernel.Bind<IDataSource>().To<DataSourceOne>()
.WithConstructorArgument("settings", Kernel.Get<ISettings>(
new ConstructorArgument("data", objectContainingConfigFileData)
)
);
in that case Ninject injects Settings class instead of DataSourceSettings class. I assume the problem is that the ISettings is getting resolved before it is injected into the DataSourceSettings class so Ninject does not use the binding I intended it to. Is there a way to get around this. I haven't found anything yet.
It should work if you define the constructor argument for the ISettings binding and not for the DataSource binding. Assuming you already know the object with the config file data in the module. Otherwise maybe a factory would be more appropriate.
kernel.Bind<IDataSource>().To<DataSourceOne>();
kernel.Bind<ISettings>().To<DataSourceSettings>()
.WhenInjectedInto<DataSourceOne>()
.WithConstructorArgument("data", objectContainingConfigFileData);
kernel.Bind<ISettings>().To<Settings>();
I am trying to run some code on objects that are loaded from RavenDB, and I need to do it just after the object has been loaded with its property values.
I've tried intercepting the deserialization process using a CustomCreationConverter and overriding ReadJson, but the object I can access at that point has all the properties set, except the one I need : the Id. Is there somewhere else I can slot into the pipeline in order to do this?
The reason you don't see the Id is because it's not part of the document, it's in the metadata as #id.
If you want to intercept client side, you can register a custom Conversion Listener. Create a class that implements IDocumentConversionListener and register it with documentStore.RegisterListener(). In the DocumentToEntity method, you can run your custom logic. The documentation is lacking on Listeners in general, but there is another topic that also uses them:
http://ravendb.net/kb/16/using-optimistic-concurrency-in-real-world-scenarios
The other option would be to add a bundle that intercepts on the server side. For that, you would use a Read Trigger.