Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to JCA and MDB

Introduction to JCA and MDB

HASUNUMA Kenji

September 30, 2017
Tweet

More Decks by HASUNUMA Kenji

Other Decks in Programming

Transcript

  1. What's JCA? • JCA (Java Connector Architecture) brings integration between

    systems • JCA is also base of Java EE servers • Almost Java EE developer have been used JCA
  2. JCA Overview External System 
 (e.g. EIS) Java EE Resource

    Adapter (.rar) Web app. (.war) Outbound Inbound Java Connector 
 Architecture (JCA)
  3. Contracts (1/2) since JCA 1.0 (J2EE 1.3) • Connection management

    (Connection pooling) • Transaction management (w/JTA) • Security management (w/JAAS)
  4. Contracts (2/2) since JCA 1.5 (J2EE 1.4) • Life cycle

    management • Work management • Transaction inflow management • Message inflow management
  5. Programming w/JCA • Many cases, JCA resource adapter is provided

    by each systems • Recently JCA is mainly used to manage message inflow • In JCA 1.7 (Java EE 7/8), properties are set by annotations
  6. Outbound @ConnectionFactoryDefinition( name = "java:comp/env/OutboundConnectionFactory", interfacename = com.example.jca.OutboundConnectionFactory, resourceAdapter =

    "some-rar", ... ) @Stateless public class ExampleMessageSender { @Resource(lookup = "java.comp/env/OutboundConnectionFactory") OutboundConnectionFactory factory; public void send(...) { try (OutboundConnection conn = factory.createConnection()) { ... } catch (Exception e) { ... } } }
  7. Attention • Session Bean SHOULD NOT be used to listen

    messages • SHOULD use Message Driven Bean (MDB) to listen messages
  8. What's MDB? • EJB specified for listening messages • Have

    a callback method and handle inbound messages provided by JCA • MDB adapts both async and sync communication
  9. Inbound @MessageDriven( activationConfig = { @ActivationConfigProperty(propertyName = ..., propertyValue =

    ...), ... } ) public class ExampleMessageListener implements MessageListener { public void onMessage(Message message) { ... } } Callback method invoked by the Resource Adapter
  10. Use case: Payara Micro • Payara Micro connects other systems

    on cloud via JCA adapters; • Apache Kafka • MQTT (Mosquitto, etc.) • Amazon SQS • Microsoft Azure Service Bus
  11. Why MQ? • System/service requirements are different each other •

    Now various systems/services are integrated on cloud platforms • MQ (i.g. Async) often resolves impedance matching between each systems/services
  12. JCA is ... • JCA (Java Connector Architecture) brings integration

    between systems • JCA is also base of Java EE servers, e.g. JMS, JDBC • Almost Java EE developer have been used JCA as JDBC data source