Message type for Object type (JAVA)
Hello,
First things first, I'm a complete newb regarding Solace PubSub+. I'm trying to build a library to be used as a dependency that will deal with all the solace communication. In my case, I want the library to be abstract in a way where it does not care about what kind of information it is dealing with. My problem is that I don't really know how to:
- Publish only on method call - I could only make it publish periodically
- Or actually feed the Message prior to sending - on a different approach I had compared to the first point.
I'm using Spring Cloud for this, and my Solace configurations are within the library's application.yml (also tried to set on code but no good, so far) and the topics information is coming from the services, that are going to use the library, application.yml. This bit works completely fine.
Approach #1
Using "spring.cloud.function.definition" I was able to make the service use the library's pub/sub functions but it was calling the publish function on a loop - no good for me
Approach #2
Tried to create Publisher and Subscriber classes but I'm struggling to make the actual publishing and subscribing...
Back to my problem, TextMessage, BytesXMLMessage, and the rest, none of them accept any object to be created... please, help...
Answers
-
Hi @RicsNsuka,
Welcome to the Solace Community! I hope you have a great first experience with PubSub+.
With Spring Cloud Stream you can use
StreamBridge
to send messages from anywhere that you need to. Since you're new to Spring Cloud Stream I'd suggest taking a little bit of time to read through their docs (their reference guide) on the Spring site, and also checking out a few codelabs that we have available.- Spring Cloud Stream Basics
- Spring Cloud Stream - Beyond the Basics (Section 6 in this one covers StreamBridge)
It sounds like you're trying to do something similar to @mdavis does in this repo where his
MessagingService
has asend
method that hisEndpointController
calls on demand. https://github.com/damaru-inc/scs-sample/tree/master/src/main/java/com/damaru/scs/scssampleHope that helps!
0