BEA Logo BEA MessageQ Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   MessageQ Doc Home   |   LU6.2 Services for OpenVMS User's Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Examples of BEA MessageQ LU6.2 Inbound and Outbound Applications

 

The following sections provide sample Inbound and Outbound applications that exchange data with an APPC application in an SNA network. These sample applications are created using the tables described in Developing Applications Using BEA MessageQ LU6.2 Services.

Sample Inbound Application

-------------------------------------------------------------------------------- 
/*
** Copyright (c) BEA Systems, Inc., 1999
** All Rights Reserved.
**
** This software is furnished under a license and may be used and copied
** only in accordance with the terms of such license and with the
** inclusion of the above copyright notice. This software or any other
** copies thereof may not be provided or otherwise made available to any
** other person. No title to and ownership of the software is hereby
** transferred.
**
** The information in this software is subject to change without notice
** and should not be construed as a commitment by BEA Systems, Inc.
**
**
** FILE: inbound.c
**
** DESCRIPTION: Illustrates the use of BEA MessageQ LU6.2 Services
** to implement an application that activates an
** Inbound application and exchanges data with an
** APPC application in an SNA network.
**
** REQUIREMENTS: The queue named "LU62_SERVER" must
** be defined in your init file and must translate
** to the group and queue of the DMQ LU6.2 Port Server
**
*/


/** ......................... **/
/** BEA MessageQ include files **/
/** ......................... **/

#include <p_entry.h>
#include <p_return.h>
#include <p_symbol.h>
#include <p_typecl.h>
#include <pamslu62_server_msg.h>

/** ....................... **/
/** C library include files **/
/** ....................... **/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


/*
** Set a max user message size
*/

#define MAX_USER_MESSAGE_SIZE 4096

/*
** Define values for states: use an enumerated type here
** to make sure each value is unique
*/
typedef enum {
STATE_UNDEFINED,
STATE_CONNECTING,
STATE_WAIT_CONNECT,
STATE_WAIT_RESPONSE,
STATE_WAIT_COMPLETE,
STATE_EXITING,
STATE_LAST
} aState;

/*
** Define a UNION for all messages, with a buffer
*/
typedef union _lu62_msg {
/*
** PORT_SERVER messages
*/
register_target regist;
connect_request conreq;
data_message data;
connection_terminated term;
connect_accept accept;
connect_reject reject;
change_direction change;
/*
** buffer area
*/
char p_buffer[MAX_USER_MESSAGE_SIZE-8]; /*
** the 8 byte adjustment allows for the maximum
** overhead in any Port Server message */

} Lu62Msg;

/*
** Routine to attach a queue so the application can send and
** receive BEA MessageQ traffic
*/
int32
AttachQueue(q_address *q_attached)
{
int32 status;
int32 attach_mode;
int32 q_type;

attach_mode = PSYM_ATTACH_TEMPORARY;
q_type = PSYM_ATTACH_PQ; /* causes the tempory queue to be */
/* a temporary primary queue */

status = pams_attach_q(
&attach_mode,
q_attached,
&q_type, /* make a temp primary queue */
(char *) 0, /* q_name not needed */
(int32 *) 0, /* q_name_len not needed */
(int32 *) 0, /* Use default name space */
(int32 *) 0, /* No name space list len */ <

Sample Outbound Application

 
--------------------------------------------------------------------------------
/*
** Copyright (c) BEA Systems, Inc., 1999
** All Rights Reserved.
**
** This software is furnished under a license and may be used and copied
** only in accordance with the terms of such license and with the
** inclusion of the above copyright notice. This software or any other
** copies thereof may not be provided or otherwise made available to any
** other person. No title to and ownership of the software is hereby
** transferred.

**
** The information in this software is subject to change without notice
** and should not be construed as a commitment by BEA Systems, Inc.
**
**
** FILE: outbound.c
**
** DESCRIPTION: Illustrates the use of BEA MessageQ LU6.2 Services
** to implement an application that waits for data to
** arrive on an outbound (from IBM) conversation, and
** exchanges data with the initiating APPC application
** in an SNA network.
**
** REQUIREMENTS: The queue named "LU62_SERVER" must
** be defined in your init file and must translate
** to the group and queue of the DMQ LU6.2 Port Server
**
**
*/

/** ......................... **/
/** BEA MessageQ include files **/
/** ......................... **/

#include <p_entry.h>
#include <p_return.h>
#include <p_symbol.h>
#include <p_typecl.h>
#include <pamslu62_server_msg.h>

/** ....................... **/
/** C library include files **/
/** ....................... **/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


/*
** Set a max user message size
*/

#define MAX_USER_MESSAGE_SIZE 4096

/*
** Define values for states: use an enumerated type here
** to make sure each value is unique
*/
typedef enum {
STATE_UNDEFINED,
STATE_REGISTERING,
STATE_WAIT_REGISTER,
STATE_WAIT_DATA,
STATE_WAIT_TO_SEND,
STATE_WAIT_DISCONNECT,
STATE_EXITING,
STATE_LAST
} aState;
/*
** Define a UNION for all messages, with a buffer
*/

typedef union _lu62_msg {
/*
** PORT_SERVER messages
*/
register_target regist;
connect_request conreq;
data_message data;
connection_terminated term;
connect_accept accept;
connect_reject reject;
change_direction change;
/*
** buffer area
*/
char p_buffer[MAX_USER_MESSAGE_SIZE-8]; /*
** The 8 byte adjustment allows for the maximum overhead in any Port
** Server message.
*/

} Lu62Msg;


/*
** Routine to attach a queue so the application can send and
** receive BEA MessageQ traffic
*/
int32
AttachQueue(q_address *q_attached)
{
int32 status;
int32 attach_mode;
int32 q_type;

attach_mode = PSYM_ATTACH_TEMPORARY;
q_type = PSYM_ATTACH_PQ; /* causes the tempory queue to be */
/* a temporary primary queue */

status = pams_attach_q(
&attach_mode,
q_attached,
&q_type, /* make a temp primary queue */
(char *) 0, /* q_name not needed */
(int32 *) 0, /* q_name_len not needed */