Simples Assim

How to Receive a Message from an Apache ActiveMQ Topic with Apache Camel

leave a comment »

W/o Durability

SampleActiveMQRouteBuilder.java

package br.eti.fernandoribeiro.sample.activemq;

import org.apache.camel.builder.RouteBuilder;

public final class SampleActiveMQRouteBuilder extends RouteBuilder {

  @Override
  public void configure() {
    from("activemq:topic:SampleTopic")...;
  }

}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>
  <bean id="sampleActiveMQRouteBuilder" class="br.eti.fernandoribeiro.sample.activemq.SampleActiveMQRouteBuilder" />
  <camel:camelContext>
    <camel:routeBuilder ref="sampleActiveMQRouteBuilder" />
  </camel:camelContext>
</beans>

W/ Durability

SampleActiveMQRouteBuilder.java

package br.eti.fernandoribeiro.sample.activemq;

import org.apache.camel.builder.RouteBuilder;

public final class SampleActiveMQRouteBuilder extends RouteBuilder {

  @Override
  public void configure() {
    from("activemq:topic:SampleTopic?clientId=SampleClient&durableSubscriptionName=SampleSubscription")...;
  }

}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>
  <bean id="sampleActiveMQRouteBuilder" class="br.eti.fernandoribeiro.sample.activemq.SampleActiveMQRouteBuilder" />
  <camel:camelContext>
    <camel:routeBuilder ref="sampleActiveMQRouteBuilder" />
  </camel:camelContext>
</beans>
About these ads

Written by Fernando Ribeiro

April 21, 2014 at 1:34 am

Posted in Software

Tagged with , , ,

How to Receive a Message from an Apache ActiveMQ Queue with Apache Camel

leave a comment »

SampleActiveMQRouteBuilder.java

package br.eti.fernandoribeiro.sample.activemq;

import org.apache.camel.builder.RouteBuilder;

public final class SampleActiveMQRouteBuilder extends RouteBuilder {

  @Override
  public void configure() {
    from("activemq:SampleQueue")...;
  }

}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>
  <bean id="sampleActiveMQRouteBuilder" class="br.eti.fernandoribeiro.sample.activemq.SampleActiveMQRouteBuilder" />
  <camel:camelContext>
    <camel:routeBuilder ref="sampleActiveMQRouteBuilder" />
  </camel:camelContext>
</beans>

Written by Fernando Ribeiro

April 21, 2014 at 1:33 am

Posted in Software

Tagged with , , ,

How to Send a Message to an Apache ActiveMQ Topic with Apache Camel

leave a comment »

package br.eti.fernandoribeiro.sample.activemq;

import org.apache.camel.builder.RouteBuilder;

public final class SampleActiveMQRouteBuilder extends RouteBuilder {

  @Override
  public void configure() {
    ...setBody(constant("Simples Assim")).to("activemq:topic:SampleTopic");
  }

}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>
  <bean id="sampleActiveMQRouteBuilder" class="br.eti.fernandoribeiro.sample.activemq.SampleActiveMQRouteBuilder" />
  <camel:camelContext>
    <camel:routeBuilder ref="sampleActiveMQRouteBuilder" />
  </camel:camelContext>
</beans>

Written by Fernando Ribeiro

April 21, 2014 at 1:32 am

Posted in Software

Tagged with , , ,

How to Send a Message to an Apache ActiveMQ Queue with Apache Camel

leave a comment »

package br.eti.fernandoribeiro.sample.activemq;

import org.apache.camel.builder.RouteBuilder;

public final class SampleActiveMQRouteBuilder extends RouteBuilder {

  @Override
  public void configure() {
    ...setBody(constant("Simples Assim")).to("activemq:SampleQueue");
  }

}

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>
  <bean id="sampleActiveMQRouteBuilder" class="br.eti.fernandoribeiro.sample.activemq.SampleActiveMQRouteBuilder" />
  <camel:camelContext>
    <camel:routeBuilder ref="sampleActiveMQRouteBuilder" />
  </camel:camelContext>
</beans>

Written by Fernando Ribeiro

April 21, 2014 at 1:31 am

Posted in Software

Tagged with , , ,

Node.js-Compatible Frameworks for the JVM

leave a comment »

Written by Fernando Ribeiro

April 20, 2014 at 8:59 pm

Posted in Software

Tagged with , , ,

How to Receive a Message from an Apache ActiveMQ Topic with GNU COBOL

leave a comment »

W/o Durability

ACTIVEMQSAMPLE.cbl

IDENTIFICATION DIVISION.

PROGRAM-ID. ACTIVEMQSAMPLE.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

DATA DIVISION.

WORKING-STORAGE SECTION.

COPY EZADATA.

PROCEDURE DIVISION.

PERFORM EZA-INITAPI.

PERFORM EZA-SOCKET.

MOVE 61613 TO EZA-NAME-PORT.

PERFORM EZA-CONNECT.

MOVE 'CONNECT' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 10 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV. *> Skip the CONNECTED frame

MOVE 'SUBSCRIBE' & X'0A' & 'destination:/topic/SampleTopic' & X'0A' & 'ack:auto' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 52 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV.

MOVE 'DISCONNECT' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 13 TO EZA-NBYTE.

PERFORM EZA-SEND.

PERFORM EZA-CLOSE.

PERFORM EZA-TERMAPI.

GOBACK.

COPY INITAPI.

COPY SOCKET.

COPY CONNECT.

COPY SEND.

COPY RECV.

COPY CLOSE.

COPY TERMAPI.

EZADATA.cpy

01 EZA-CALL-DATA.
  05 EZA-FUNCTION PIC X(16).
  05 EZA-AF PIC S9(9) COMP.
  05 EZA-BACKLOG PIC S9(9) COMP.
  05 EZA-CLIENT.
    10 EZA-CLIENT-DOMAIN PIC S9(9) COMP.
    10 EZA-CLIENT-NAME PIC X(8).
    10 EZA-CLIENT-TASK PIC X(8).
    10 FILLER PIC X(20).
  05 EZA-COMMAND-X.
    10 EZA-COMMAND PIC S9(9) COMP.
  05 EZA-FLAGS PIC S9(9) COMP.
  05 EZA-HOSTADDR PIC X(4).
  05 EZA-HOSTENT POINTER.
  05 EZA-HOW PIC S9(9) COMP.
  05 EZA-IDENT.
    10 EZA-IDENT-TCPNAME.
        15 EZA-IDENT-TAG PIC X(6).
        15 EZA-IDENT-SYSID PIC X(2).
    10 EZA-IDENT-ADSNAME PIC X(8).
  05 EZA-MAXSNO PIC S9(9) COMP.
  05 EZA-MAXSOC PIC S9(4) COMP.
  05 EZA-MAXSOC-SELECT PIC S9(9) COMP.
  05 EZA-NAME.
    10 EZA-NAME-FAMILY PIC S9(4) COMP.
    10 EZA-NAME-PORT PIC 9(4) COMP.
    10 EZA-NAME-IPADDRESS PIC X(4).
    10 FILLER PIC X(8).
  05 EZA-NAMELEN PIC S9(8) COMP.
  05 EZA-NBYTE PIC S9(9) COMP.
  05 EZA-OPTLEN PIC S9(9) COMP.
  05 EZA-OPTNAME PIC S9(9) COMP.
  05 EZA-OPTVALUE PIC X(16).
  05 EZA-PROTO PIC S9(9) COMP.
  05 EZA-RETCODE PIC S9(9) COMP.
  05 EZA-S-X.
    10 EZA-S PIC S9(4) COMP.
    10 EZA-S-ACCEPT PIC S9(4) COMP.
  05 EZA-SOCRECV PIC S9(4) COMP.
  05 EZA-SOCTYPE PIC S9(9) COMP.
    88 EZA-SOCTYPE-STREAM VALUE +1.
    88 EZA-SOCTYPE-DATAGRAM VALUE +2.
  05 EZA-SUBTASK PIC X(8).
  05 EZA-TIMEOUT.
    10 EZA-TIMEOUT-SECONDS PIC S9(9) COMP.
    10 EZA-TIMEOUT-MICROS PIC S9(9) COMP.
  05 EZA-NAME-STR PIC X(255).
  05 EZA-PROGRAM PIC X(8).
  05 EZA-IOVCNT PIC 9(8) COMP.
  05 EZA-ERRNO PIC S9(9) COMP.
    88 EZA-ERRNO-EAFNOSUPPORT VALUE 97.
    88 EZA-ERRNO-ENAMETOOLONG VALUE 36.
    88 EZA-ERRNO-EINVAL VALUE 22.
    88 EZA-ERRNO-EPROTOTYPE VALUE 91.
    88 EZA-ERRNO-EACCES VALUE 13.
    88 EZA-ERRNO-EADDRINUSE VALUE 98.
    88 EZA-ERRNO-ENOTSOCK VALUE 88.
    88 EZA-ERRNO-EADDRNOTAVAIL VALUE 99.
    88 EZA-ERRNO-EBADF VALUE 9.
    88 EZA-ERRNO-EOPNOTSUPP VALUE 95.
    88 EZA-ERRNO-ECONNREFUSED VALUE 111.
    88 EZA-ERRNO-EISCONN VALUE 106.
    88 EZA-ERRNO-ENETUNREACH VALUE 101.
    88 EZA-ERRNO-EPROTONOSUPPORT VALUE 93.
    88 EZA-ERRNO-EAGAIN VALUE 11.

01 EZA-BUFFER PIC X(1000).

01 EZA-IOV.
  03 EZA-IOV-ENTRY OCCURS 4 TIMES.
    05 EZA-IOV-BUFFER USAGE IS POINTER.
    05 EZA-IOV-RESERVED PIC X(4).
    05 EZA-IOV-BUFFER-LEN PIC 9(8) COMP.

01 EZA-MSG.
  05 EZA-MSG-NAME USAGE IS POINTER.
  05 EZA-MSG-NAMELENGTH USAGE IS POINTER.
  05 EZA-MSG-IOV USAGE IS POINTER.
  05 EZA-MSG-IOVCNT USAGE IS POINTER.
  05 EZA-MSG-ACCRIGHTS USAGE IS POINTER.
  05 EZA-MSG-ACCRLEN USAGE IS POINTER.

01 ABEND-INFORMATION.
  05 ABEND-CODE PIC 9(4) VALUE ZEROS.

INITAPI.cpy

EZA-INITAPI SECTION.
  MOVE 'INITAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-MAXSOC EZA-IDENT EZA-SUBTASK EZA-MAXSNO EZA-ERRNO EZA-RETCODE.

SOCKET.cpy

EZA-SOCKET SECTION.
  MOVE 'SOCKET' TO EZA-FUNCTION.

  MOVE 2 TO EZA-AF. *> IPV4

  MOVE 1 TO EZA-SOCTYPE. *> TCP

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-AF EZA-SOCTYPE EZA-PROTO EZA-ERRNO EZA-RETCODE.

  MOVE EZA-RETCODE TO EZA-S.

CONNECT.cpy

EZA-CONNECT SECTION.
  MOVE 'CONNECT' TO EZA-FUNCTION.

  MOVE 2 TO EZA-NAME-FAMILY. *> IPV4

  MOVE LOW-VALUES TO EZA-NAME-IPADDRESS. *> NULL

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S EZA-NAME EZA-ERRNO EZA-RETCODE.

  MOVE EZA-S TO EZA-S-ACCEPT.

SEND.cpy

EZA-SEND SECTION.
  MOVE 'SEND' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE.

RECV.cpy

EZA-RECV SECTION.
  MOVE 'RECV' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE.

CLOSE.cpy

EZA-CLOSE SECTION.
  MOVE 'CLOSE' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-ERRNO EZA-RETCODE.

TERMAPI.cpy

EZA-TERMAPI SECTION.
  MOVE 'TERMAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION.

W/ Durability

ACTIVEMQSAMPLE.cbl

IDENTIFICATION DIVISION.

PROGRAM-ID. ACTIVEMQSAMPLE.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

DATA DIVISION.

WORKING-STORAGE SECTION.

COPY EZADATA.

PROCEDURE DIVISION.

PERFORM EZA-INITAPI.

PERFORM EZA-SOCKET.

MOVE 61613 TO EZA-NAME-PORT.

PERFORM EZA-CONNECT.

MOVE 'CONNECT' & X'0A' & 'client-id:SampleClient' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 33 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV. *> Skip the CONNECTED frame

MOVE 'SUBSCRIBE' & X'0A' & 'destination:/topic/SampleTopic' & X'0A' & 'ack:auto' & X'0A' & 'activemq.subscriptionName:SampleSubscription' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 97 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV.

MOVE 'DISCONNECT' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 13 TO EZA-NBYTE.

PERFORM EZA-SEND.

PERFORM EZA-CLOSE.

PERFORM EZA-TERMAPI.

GOBACK.

COPY INITAPI.

COPY SOCKET.

COPY CONNECT.

COPY SEND.

COPY RECV.

COPY CLOSE.

COPY TERMAPI.

EZADATA.cpy

01 EZA-CALL-DATA.
  05 EZA-FUNCTION PIC X(16).
  05 EZA-AF PIC S9(9) COMP.
  05 EZA-BACKLOG PIC S9(9) COMP.
  05 EZA-CLIENT.
    10 EZA-CLIENT-DOMAIN PIC S9(9) COMP.
    10 EZA-CLIENT-NAME PIC X(8).
    10 EZA-CLIENT-TASK PIC X(8).
    10 FILLER PIC X(20).
  05 EZA-COMMAND-X.
    10 EZA-COMMAND PIC S9(9) COMP.
  05 EZA-FLAGS PIC S9(9) COMP.
  05 EZA-HOSTADDR PIC X(4).
  05 EZA-HOSTENT POINTER.
  05 EZA-HOW PIC S9(9) COMP.
  05 EZA-IDENT.
    10 EZA-IDENT-TCPNAME.
        15 EZA-IDENT-TAG PIC X(6).
        15 EZA-IDENT-SYSID PIC X(2).
    10 EZA-IDENT-ADSNAME PIC X(8).
  05 EZA-MAXSNO PIC S9(9) COMP.
  05 EZA-MAXSOC PIC S9(4) COMP.
  05 EZA-MAXSOC-SELECT PIC S9(9) COMP.
  05 EZA-NAME.
    10 EZA-NAME-FAMILY PIC S9(4) COMP.
    10 EZA-NAME-PORT PIC 9(4) COMP.
    10 EZA-NAME-IPADDRESS PIC X(4).
    10 FILLER PIC X(8).
  05 EZA-NAMELEN PIC S9(8) COMP.
  05 EZA-NBYTE PIC S9(9) COMP.
  05 EZA-OPTLEN PIC S9(9) COMP.
  05 EZA-OPTNAME PIC S9(9) COMP.
  05 EZA-OPTVALUE PIC X(16).
  05 EZA-PROTO PIC S9(9) COMP.
  05 EZA-RETCODE PIC S9(9) COMP.
  05 EZA-S-X.
    10 EZA-S PIC S9(4) COMP.
    10 EZA-S-ACCEPT PIC S9(4) COMP.
  05 EZA-SOCRECV PIC S9(4) COMP.
  05 EZA-SOCTYPE PIC S9(9) COMP.
    88 EZA-SOCTYPE-STREAM VALUE +1.
    88 EZA-SOCTYPE-DATAGRAM VALUE +2.
  05 EZA-SUBTASK PIC X(8).
  05 EZA-TIMEOUT.
    10 EZA-TIMEOUT-SECONDS PIC S9(9) COMP.
    10 EZA-TIMEOUT-MICROS PIC S9(9) COMP.
  05 EZA-NAME-STR PIC X(255).
  05 EZA-PROGRAM PIC X(8).
  05 EZA-IOVCNT PIC 9(8) COMP.
  05 EZA-ERRNO PIC S9(9) COMP.
    88 EZA-ERRNO-EAFNOSUPPORT VALUE 97.
    88 EZA-ERRNO-ENAMETOOLONG VALUE 36.
    88 EZA-ERRNO-EINVAL VALUE 22.
    88 EZA-ERRNO-EPROTOTYPE VALUE 91.
    88 EZA-ERRNO-EACCES VALUE 13.
    88 EZA-ERRNO-EADDRINUSE VALUE 98.
    88 EZA-ERRNO-ENOTSOCK VALUE 88.
    88 EZA-ERRNO-EADDRNOTAVAIL VALUE 99.
    88 EZA-ERRNO-EBADF VALUE 9.
    88 EZA-ERRNO-EOPNOTSUPP VALUE 95.
    88 EZA-ERRNO-ECONNREFUSED VALUE 111.
    88 EZA-ERRNO-EISCONN VALUE 106.
    88 EZA-ERRNO-ENETUNREACH VALUE 101.
    88 EZA-ERRNO-EPROTONOSUPPORT VALUE 93.
    88 EZA-ERRNO-EAGAIN VALUE 11.

01 EZA-BUFFER PIC X(1000).

01 EZA-IOV.
  03 EZA-IOV-ENTRY OCCURS 4 TIMES.
    05 EZA-IOV-BUFFER USAGE IS POINTER.
    05 EZA-IOV-RESERVED PIC X(4).
    05 EZA-IOV-BUFFER-LEN PIC 9(8) COMP.

01 EZA-MSG.
  05 EZA-MSG-NAME USAGE IS POINTER.
  05 EZA-MSG-NAMELENGTH USAGE IS POINTER.
  05 EZA-MSG-IOV USAGE IS POINTER.
  05 EZA-MSG-IOVCNT USAGE IS POINTER.
  05 EZA-MSG-ACCRIGHTS USAGE IS POINTER.
  05 EZA-MSG-ACCRLEN USAGE IS POINTER.

01 ABEND-INFORMATION.
  05 ABEND-CODE PIC 9(4) VALUE ZEROS.

INITAPI.cpy

EZA-INITAPI SECTION.
  MOVE 'INITAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-MAXSOC EZA-IDENT EZA-SUBTASK EZA-MAXSNO EZA-ERRNO EZA-RETCODE.

SOCKET.cpy

EZA-SOCKET SECTION.
  MOVE 'SOCKET' TO EZA-FUNCTION.

  MOVE 2 TO EZA-AF. *> IPV4

  MOVE 1 TO EZA-SOCTYPE. *> TCP

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-AF EZA-SOCTYPE EZA-PROTO EZA-ERRNO EZA-RETCODE.

  MOVE EZA-RETCODE TO EZA-S.

CONNECT.cpy

EZA-CONNECT SECTION.
  MOVE 'CONNECT' TO EZA-FUNCTION.

  MOVE 2 TO EZA-NAME-FAMILY. *> IPV4

  MOVE LOW-VALUES TO EZA-NAME-IPADDRESS. *> NULL

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S EZA-NAME EZA-ERRNO EZA-RETCODE.

  MOVE EZA-S TO EZA-S-ACCEPT.

SEND.cpy

EZA-SEND SECTION.
  MOVE 'SEND' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE.

RECV.cpy

EZA-RECV SECTION.
  MOVE 'RECV' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE

CLOSE.cpy

EZA-CLOSE SECTION.
  MOVE 'CLOSE' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-ERRNO EZA-RETCODE.

TERMAPI.cpy

EZA-TERMAPI SECTION.
  MOVE 'TERMAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION.

Written by Fernando Ribeiro

April 17, 2014 at 9:06 pm

Posted in Software

Tagged with , , , ,

How to Receive a Message from an Apache ActiveMQ Queue with GNU COBOL

leave a comment »

ACTIVEMQSAMPLE.cbl

IDENTIFICATION DIVISION.

PROGRAM-ID. ACTIVEMQSAMPLE.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

DATA DIVISION.

WORKING-STORAGE SECTION.

COPY EZADATA.

PROCEDURE DIVISION.

PERFORM EZA-INITAPI.

PERFORM EZA-SOCKET.

MOVE 61613 TO EZA-NAME-PORT.

PERFORM EZA-CONNECT.

MOVE 'CONNECT' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 10 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV. *> Skip the CONNECTED frame

MOVE 'SUBSCRIBE' & X'0A' & 'destination:SampleQueue' & X'0A' & 'ack:auto' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 45 TO EZA-NBYTE.

PERFORM EZA-SEND.

MOVE 1000 TO EZA-NBYTE.

PERFORM EZA-RECV.

MOVE 'DISCONNECT' & X'0A' & X'0A' & X'00' TO EZA-BUFFER.

MOVE 13 TO EZA-NBYTE.

PERFORM EZA-SEND.

PERFORM EZA-CLOSE.

PERFORM EZA-TERMAPI.

GOBACK.

COPY INITAPI.

COPY SOCKET.

COPY CONNECT.

COPY SEND.

COPY RECV.

COPY CLOSE.

COPY TERMAPI.

EZADATA.cpy

01 EZA-CALL-DATA.
  05 EZA-FUNCTION PIC X(16).
  05 EZA-AF PIC S9(9) COMP.
  05 EZA-BACKLOG PIC S9(9) COMP.
  05 EZA-CLIENT.
    10 EZA-CLIENT-DOMAIN PIC S9(9) COMP.
    10 EZA-CLIENT-NAME PIC X(8).
    10 EZA-CLIENT-TASK PIC X(8).
    10 FILLER PIC X(20).
  05 EZA-COMMAND-X.
    10 EZA-COMMAND PIC S9(9) COMP.
  05 EZA-FLAGS PIC S9(9) COMP.
  05 EZA-HOSTADDR PIC X(4).
  05 EZA-HOSTENT POINTER.
  05 EZA-HOW PIC S9(9) COMP.
  05 EZA-IDENT.
    10 EZA-IDENT-TCPNAME.
        15 EZA-IDENT-TAG PIC X(6).
        15 EZA-IDENT-SYSID PIC X(2).
    10 EZA-IDENT-ADSNAME PIC X(8).
  05 EZA-MAXSNO PIC S9(9) COMP.
  05 EZA-MAXSOC PIC S9(4) COMP.
  05 EZA-MAXSOC-SELECT PIC S9(9) COMP.
  05 EZA-NAME.
    10 EZA-NAME-FAMILY PIC S9(4) COMP.
    10 EZA-NAME-PORT PIC 9(4) COMP.
    10 EZA-NAME-IPADDRESS PIC X(4).
    10 FILLER PIC X(8).
  05 EZA-NAMELEN PIC S9(8) COMP.
  05 EZA-NBYTE PIC S9(9) COMP.
  05 EZA-OPTLEN PIC S9(9) COMP.
  05 EZA-OPTNAME PIC S9(9) COMP.
  05 EZA-OPTVALUE PIC X(16).
  05 EZA-PROTO PIC S9(9) COMP.
  05 EZA-RETCODE PIC S9(9) COMP.
  05 EZA-S-X.
    10 EZA-S PIC S9(4) COMP.
    10 EZA-S-ACCEPT PIC S9(4) COMP.
  05 EZA-SOCRECV PIC S9(4) COMP.
  05 EZA-SOCTYPE PIC S9(9) COMP.
    88 EZA-SOCTYPE-STREAM VALUE +1.
    88 EZA-SOCTYPE-DATAGRAM VALUE +2.
  05 EZA-SUBTASK PIC X(8).
  05 EZA-TIMEOUT.
    10 EZA-TIMEOUT-SECONDS PIC S9(9) COMP.
    10 EZA-TIMEOUT-MICROS PIC S9(9) COMP.
  05 EZA-NAME-STR PIC X(255).
  05 EZA-PROGRAM PIC X(8).
  05 EZA-IOVCNT PIC 9(8) COMP.
  05 EZA-ERRNO PIC S9(9) COMP.
    88 EZA-ERRNO-EAFNOSUPPORT VALUE 97.
    88 EZA-ERRNO-ENAMETOOLONG VALUE 36.
    88 EZA-ERRNO-EINVAL VALUE 22.
    88 EZA-ERRNO-EPROTOTYPE VALUE 91.
    88 EZA-ERRNO-EACCES VALUE 13.
    88 EZA-ERRNO-EADDRINUSE VALUE 98.
    88 EZA-ERRNO-ENOTSOCK VALUE 88.
    88 EZA-ERRNO-EADDRNOTAVAIL VALUE 99.
    88 EZA-ERRNO-EBADF VALUE 9.
    88 EZA-ERRNO-EOPNOTSUPP VALUE 95.
    88 EZA-ERRNO-ECONNREFUSED VALUE 111.
    88 EZA-ERRNO-EISCONN VALUE 106.
    88 EZA-ERRNO-ENETUNREACH VALUE 101.
    88 EZA-ERRNO-EPROTONOSUPPORT VALUE 93.
    88 EZA-ERRNO-EAGAIN VALUE 11.

01 EZA-BUFFER PIC X(1000).

01 EZA-IOV.
  03 EZA-IOV-ENTRY OCCURS 4 TIMES.
    05 EZA-IOV-BUFFER USAGE IS POINTER.
    05 EZA-IOV-RESERVED PIC X(4).
    05 EZA-IOV-BUFFER-LEN PIC 9(8) COMP.

01 EZA-MSG.
  05 EZA-MSG-NAME USAGE IS POINTER.
  05 EZA-MSG-NAMELENGTH USAGE IS POINTER.
  05 EZA-MSG-IOV USAGE IS POINTER.
  05 EZA-MSG-IOVCNT USAGE IS POINTER.
  05 EZA-MSG-ACCRIGHTS USAGE IS POINTER.
  05 EZA-MSG-ACCRLEN USAGE IS POINTER.

01 ABEND-INFORMATION.
  05 ABEND-CODE PIC 9(4) VALUE ZEROS.

INITAPI.cpy

EZA-INITAPI SECTION.
  MOVE 'INITAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-MAXSOC EZA-IDENT EZA-SUBTASK EZA-MAXSNO EZA-ERRNO EZA-RETCODE.

SOCKET.cpy

EZA-SOCKET SECTION.
  MOVE 'SOCKET' TO EZA-FUNCTION.

  MOVE 2 TO EZA-AF. *> IPV4

  MOVE 1 TO EZA-SOCTYPE. *> TCP

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-AF EZA-SOCTYPE EZA-PROTO EZA-ERRNO EZA-RETCODE.

  MOVE EZA-RETCODE TO EZA-S.

CONNECT.cpy

EZA-CONNECT SECTION.
  MOVE 'CONNECT' TO EZA-FUNCTION.

  MOVE 2 TO EZA-NAME-FAMILY. *> IPV4

  MOVE LOW-VALUES TO EZA-NAME-IPADDRESS. *> NULL

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S EZA-NAME EZA-ERRNO EZA-RETCODE.

  MOVE EZA-S TO EZA-S-ACCEPT.

SEND.cpy

EZA-SEND SECTION.
  MOVE 'SEND' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE.

RECV.cpy

EZA-RECV SECTION.
  MOVE 'RECV' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-FLAGS EZA-NBYTE EZA-BUFFER EZA-ERRNO EZA-RETCODE

CLOSE.cpy

EZA-CLOSE SECTION.
  MOVE 'CLOSE' TO EZA-FUNCTION

  CALL 'EZASOKET' USING EZA-FUNCTION EZA-S-ACCEPT EZA-ERRNO EZA-RETCODE.

TERMAPI.cpy

EZA-TERMAPI SECTION.
  MOVE 'TERMAPI' TO EZA-FUNCTION.

  CALL 'EZASOKET' USING EZA-FUNCTION.

Written by Fernando Ribeiro

April 17, 2014 at 9:04 pm

Posted in Software

Tagged with , , , ,

Follow

Get every new post delivered to your Inbox.

Join 1,141 other followers