Is Objectstore Not Shared Through Cluster Environment? - mule

I have an API that is called via scheduler and I want to store a variable so that the next time the scheduler kicks in it somehow recalls that variable (count) and increment it. I tried using objectstore here but I am having an issue since my API runs in a clustered environment. I think the objectstore value it not shared across the cluster environment. Tried changing the persistent value to false (so that it store the data in memory) but still does not work. Did I miss something or that is really how it behaves? If it is the later, is there any other possible solution knowing that saving the value in actual database is not feasible/available? Thank you.
Adding config for the objectstore
<os:object-store name="CounterStore" doc:name="Object store" doc:id="5e0b1de8-318f-49b1-ab7f-47d29f1631d2" persistent="false" config-ref="CounterStoreConfig"/>
<os:config name="CounterStoreConfig" doc:name="ObjectStore Config" doc:id="7be6b1a6-d0e0-45d4-a52a-2080a5d54802" />
We have our own domain for the anypoint platform and I'm seeing /cloudhub in the url in the runtime manager so I'm assuming that we are running in the CloudHub. We are using the Mule 4.

CloudHub does not support clusters. It does support multi worker deployments, where the same application is deployed to more than one worker. That means that the cluster object store implementation is not available in CloudHub. You can use the Object Store v1 (deprecated) or the recommended v2. Both allow to share an object store between workers. You need to name the object store according to the documentation. That means that for Mule 4/object store v2 it should be called _defaultPersistentObjectStore. Also remove the persistent attibute
https://docs.mulesoft.com/object-store/#object-store-notes:
For CloudHub applications using Mule 4, if you choose Object Store v2,
Object Store v2 overrides the _defaultPersistentObjectStore object
store.
For CloudHub applications using Mule 3, Object Store v2 overrides the
_defaultUserObjectStore object store. To use Object Store v2 in Mule 3 CloudHub applications, set the Object Store reference field to the
_defaultUserObjectStore value.
Note that Object Store implementations in CloudHub do not lock between workers so it may not be useful for you:
Using Object Store v2 with multi-worker CloudHub applications might result in data discrepancies or key clashes.

Related

why persistent check box in object store connector configuration is not enabled by default, if persistent store is default as per mule docs?

I am new to mule and trying to implement object store.
As per mule documentation:
Mule provides two types of object stores:
In-memory store – Prior to Mule 3.5.0, in-memory store was the default. As of Mule 3.5.0, persistent store is the default. For more information, see "Object Stores and Clustering" in the Cache Scope document.
Persistent store – Mule persists data when an object store is explicitly configured to be persistent. Mule creates a default persistent store in the file system.
it is mentioned as persistent store is default but in object store connector configuration persistent checkbox is not enabled by default. why it is so and which object store is used in this scenario?
Thanks in advance.
Note: Am using mule 3.8.3
Screenshot of Object store configuration
these are two different concepts. Mule Cache Scope which is what you are referring and Object Stores as a connector component itself.
If you are wrap a component in a cache scope then by default it uses 'default caching strategy' which uses inMemoryObjectStore (intended for testing only). It is better to store the cached responses in a separate store such as Object Store. Also, internally, Mule uses object stores in various filters, routers, and other message processors that need to store state between messages. In most cases, Mule creates and manages object stores automatically.
Coming to ObjectStores connector, they can be persisted to disk by proper configuration settings.
Hope this helps!
Thanks,
Anand

Using Mule variables or properties accross transport barriers

Let say I get a inbound variable from an http connector when I use this URL
http://x.x.x.x:8080/post?post-message=Hallo wold.
How can I use the value of the #[header:INBOUND:post-message] accross the complete flow from after the HTTP connector all the way up tp the end. Should I use the Mule Object store to write it to ram?
This post shows the scope of variables but it seem there is not one thay can flow from start to en like a session bean
https://m-square.com.au/mule-school-the-mulemessage-property-scopes-and-variables/
Kind Regards.
If you need the variable available throughout the whole flow (and
other flows reached through a flow-ref) use the invocation scope
(set-variable to set, flowVars[] to read it)
If you need it to reach other flows through a transport (e.g. VM) put
it in the outbound or session scope.
If you need it to live as long as the app is running, through
different calls, use the Mule registry (volatile, only available as
long as the app is up) or the object store (which can be configured
as persistent, to hold state even if the app goes down).
Mule Session variables are good enough to get the value throughout application.
But if you need to use the value outside your application, then you can set mule outbound properties.
There are three type of scope level variables supported by mule .
You can use flow variable if you want the variable to be accessible throughout the whole flow.
You can use session variable if you want it to be accessible form other flows through a transport barrier.
Refer this blog for getting better understanding of how different types of variables are propagated between different mule flows.
http://blogs.mulesoft.com/dev/anypoint-platform-dev/mule-school-the-mulemessage-property-scopes-and-variables/

Session variables skipping multiple requests

I understand that session variables in Mule ESB can be shared between different flows of the same request, but... How can I make a variable visible to multiple requests?
It is a variable, so it would change depending on the data the flow receive.
Thanks in advance!
you can use the new mule 3.4 cache scope to store/cache objects, alternatively you can use the Mule Objectstore to save the session value as key and object. This
can be in-memory or persistent
<objectstore:retrieve key="mykey" defaultValue-ref="myvalue"/>

lotus.domino.Session is not serialized

I had developed a Java based Lotus Domino Email Client Application. I am saving the lotus.domino.Session object in httpsession.setAttribute for session management.we decided to deploy the application on two different servers and manage load balancing and Session Replication between the two.
Now we are facing issues while Replicating lotus.domino.Session because lotus.domino.Session is not serialized.
Kindly help me
Thanks
AFAIK, you are out of luck.
Domino objects (that is, anything in the lotus.domino package) store a link to a C API object that must be garbage collected to avoid memory leaks.
As a result, if a Domino object is serialized, it will become toxic at the end of the request in which it was stored, because its C object link will have been automatically recycled at the end of that request.
As Leyrer says, it is not possible to serialise any Domino Object as it has a C-API backend component to it which cannot be stored.
Also the Session object was never designed for connection pooling either. So even if you skip the serialisation, you may encounter other issues.
Depending on what it is you are trying to accomplish, you could create your own serialisable object with just the references you need to recreate the session and any other objects.

Lifetime of static variable on windows service

I am wondering what would be the life time of a static variable in windows service. I have a windows service and static variable to save the messages flowing inside the service. will I get the messages saved on the static variable after the service is restarted?
No, static variables will revert to their original values upon application restart, and a service restart is an application restart.
That answered - if you need a transient data store for messages, you might consider using Entity Framework 4.1 code first with a simple object structure to hold your messages. The framework will create the data store for you safely and it will persist between executions.