OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 591 forks source link

BETA BLOG 19700: Reactive Messaging Beta blog post content #8104

Closed tevans78 closed 5 years ago

tevans78 commented 5 years ago

BETA BLOG 19700 We should write a paragraph or two on how to use the beta mpReactiveMessaging-1.0 feature

hutchig commented 5 years ago

I will follow the process here: https://github.ibm.com/was-liberty/WS-CD-Open/wiki/Creating-Stories-and-Features#moving-a-feature-into-a-beta and chat to @lauracowen

hutchig commented 5 years ago

1 - Create a child task of the epic 2 - with a description that starts with "BETA BLOG 19#00", where #=1,2,3, Add to the child task the labels 3 'Blog' 4 and 'release:19#00', where #=1,2,3, ... ~

Provide the appropriate text (see questionnaire) in the child task. [Questionaire answers in next box]

When the text has been provided, assign the task to Laura Cowen, Dave Barfield and the Epic feature owner.

hutchig commented 5 years ago

Questionaire from: https://apps.na.collabserv.com/wikis/home?lang=en-us#!/wiki/Wde4b45b770c2_47cd_9d6d_7061f359add9/page/Blog%20Questionnairs Beta (no betas in Open Liberty so blog posts are just updates on what's in progress but not yet in the stable/GA release; eg https://openliberty.io/blog/2018/11/23/distributed-tracing-microservices.html) Development progress update

a. Which Liberty feature does it relate to?

i. Human-readable name (eg WebSockets feature)

MicroProfile Reactive Messaging 1.0

ii. Feature name (eg websockets-1.0)

mpReactiveMessaging-1.0

iii. Is this a new feature or is it an update to an existing feature for this release?

This is a new feature

iv. Provide the qualified name of all changed feature deliveries to this release? (eg: com.ibm.websphere.appserver.transportSecurity-1.0.esa)

./cnf/release/dev/com.ibm.websphere.appserver.org.eclipse.microprofile.reactive.messaging-1.0/19.0.0.7-201907100948/com.ibm.websphere.appserver.org.eclipse.microprofile.reactive.messaging-1.0-19.0.0.7-201907100948.esa ./cnf/release/dev/com.ibm.websphere.appserver.mpReactiveMessaging-1.0/19.0.0.7-201907100948/com.ibm.websphere.appserver.mpReactiveMessaging-1.0-19.0.0.7-201907100948.esa ./com.ibm.websphere.appserver.features/build/libs/repo/com.ibm.websphere.appserver.org.eclipse.microprofile.reactive.messaging-1.0.esa ./com.ibm.websphere.appserver.features/build/libs/repo/com.ibm.websphere.appserver.mpReactiveMessaging-1.0.esa

b. Who is the target audience? eg application developers, devops pipeline devs, appserver administrators, etc

The target audience for this feature is application developers. Particularly application developers that want to send messages between components in an application, such as particular microservices that make up an application with a microservices architecture.

c. Write a sentence or two that introduces it to someone new to the general technology/concept.

An application using Reactive Messaging is composed of CDI beans consuming, producing and processing messages passing along reactive streams. These messages can be internal to the application or can be sent and received via different message brokers.

d. What is new/changed in this release and why should they get excited about this new thing (2-3 sentences)? What was the problem before and how this new feature make their life easier? (Why should they care?)

Reactive Messaging provides a very easy to use way to send, receive and process messages. With MicroProfile Reactive Messaging users can annotate application beans' methods to have messages on a particular channel '@Incoming', '@Outgoing' or both and Liberty will drive those methods appropriately as reactive streams Publishers, Subscribers or Processors.

e. Explain how to make it work. Include screenshots and/or code snippets to illustrate how to use it, if relevant. Provide server.xml snippet for how to enable the feature.

To enable the feature include it in your server.xml feature list:

  <featureManager>
    <feature>mpReactiveMessaging-1.0</feature>
    ...
  </featureManager>

With this feature in the OpenLiberty runtime an application CDI bean can have one of its methods annotated as being message driven, in the example below the method will processes messages from the "greetings" channel.

@Incoming("greetings")
publicCompletionStage <Void> consume(Message<String> greeting ){
   return greeting.ack();
}

A channel represents a stream of messages of a given type and, usually, the same topic. Channels can operate locally within the process or use message brokers to send messages between services.

For example, with no code changes we could change the consume method above to subscribe to messages from the Kafka greetings topic using a Kafka connector like so:

mp.messaging.incoming.greetings.connector=io.openliberty.kafka

The io.openliberty.kafka' connector operates according to the reactive messaging specification. For example theconsume` method above will by default be set to consume messages from a Kafka topic queue. Further Kafka client properties can be set for the channel by setting properties that will be picked up by the MicroProfile Config specification. For example - System properties via OpenLiberty's bootstrap.properties or environment variables from OpenLiberty's server.env. As per the reactive messaging specification the following configuration properties will be passed to the Kafka client:

mp.messaging.incoming.greetings.[PROPERTY-NAME]=value1
mp.messaging.connector.io.openliberty.kafka.[PROPERTY-NAME]=value2

These will get passed to the Kafka Consumer factory method as:

PROPERTY-NAME=value

So, for example, a full set of properties to access IBM Public Cloud Event Streams could look like:

mp.messaging.connector.io.openliberty.kafka.bootstrap.servers=broker-1-eventstreams.cloud.ibm.com:9093,broker-2-eventstreams.cloud.ibm.com:9093
mp.messaging.connector.io.openliberty.kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="token" password="my-apikey";
mp.messaging.connector.io.openliberty.kafka.sasl.mechanism=PLAIN
mp.messaging.connector.io.openliberty.kafka.security.protocol=SASL_SSL
mp.messaging.connector.io.openliberty.kafka.ssl.protocol=TLSv1.2

When using Kafka based channels, OpenLiberty Reactive Messaging 1.0 will load the Kafka client classes using the application classloader. If you are using the io.openliberty.kafka connector to read or write Kafka messages, include in your application a Kafka client API jar that is compatible with your Kafka server. For example, the /WEB-INF/lib/ folder would be a suitable place to place a Kafka client jar when building the application's .war file.

This is a beta release of the OpenLiberty Reactive Messaging Kafka connector. We will look to provide more support for sensible defaults and cloud binding information such as Cloud Foundry's VCAP_SERVICES environment variable in the 1.0 release.

f. Provide any public URLs where the reader can find out more about this specific update and/or about the wider technology.

MicroProfile Reactive Messaging is described in detail in the following specification https://download.eclipse.org/microprofile/microprofile-reactive-messaging-1.0/microprofile-reactive-messaging-spec.pdf

lauracowen commented 5 years ago

Thanks!