<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jotadeveloper Blog &#187; jpos</title>
	<atom:link href="http://blog.jotadeveloper.com/tag/jpos/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jotadeveloper.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 06 Sep 2010 06:44:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Paquetes genéricos en jPOS</title>
		<link>http://blog.jotadeveloper.com/2009/07/30/paquetes-genericos-en-jpos/</link>
		<comments>http://blog.jotadeveloper.com/2009/07/30/paquetes-genericos-en-jpos/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 15:23:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[empaquetado]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jpos]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2608</guid>
		<description><![CDATA[El empaquetado es una de las glorias de jPOS a mi parecer, hace un tiempo escribí como jPOS creaba el mapa de bits primario y sencudario.  Mucha gente que inicia con jPOS cree (me incluyo yo en mis inicios) que nosotros debemos setear el campo primario y el campo secundario, pero que quede claro, esto [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/uploads/2009/07/jPOSPackage1.png" rel="lightbox"><img class="aligncenter size-full wp-image-2617" title="jPOSPackage" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/07/jPOSPackage1.png" alt="jPOSPackage" width="358" height="286" /></a></p>
<p>El empaquetado es una de las glorias de <a href="http://blog.jotadeveloper.com/tag/jpos/" target="_blank">jPOS</a> a mi parecer, hace un tiempo escribí como <a href="http://blog.jotadeveloper.com/2009/03/10/crear-mapa-de-bits-primario-y-secundario-en-jpos/" target="_blank">jPOS creaba el mapa de bits primario y sencudario</a>.  Mucha gente que inicia con jPOS cree (me incluyo yo en mis inicios) que <strong>nosotros debemos setear el campo primario y el campo secundario, pero que quede claro, esto no es necesario con jPOS</strong>. Por eso vamos hablar hoy del empaquetado y el desempaquetado en jPOS, los diferentes tipos de empaquetados que el frameworks nos ofrece y el Empaquetado Genérico, para crear el empaquetado a la medida.</p>
<p>Existen 2 maneras de crear un empaquetador, primero implementando el Interfaz <strong>ISOPackager</strong> que se encuentra en el paquete  <strong>org.jpos.iso</strong> y heredando los métodos de <strong>ISOBasePackager</strong> que trae <strong>int unpack</strong> y <strong>byte[] pack</strong>. Existen muchas clases empaquetadoras en esta ubicación <strong>/org/jpos/iso/packager</strong> para diferentes tipos de protocolos de comunicación.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> ISOPackager <span style="color: #000000; font-weight: bold;">extends</span> LogSource <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> pack <span style="color: #009900;">&#40;</span>ISOComponent m<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ISOException<span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> unpack <span style="color: #009900;">&#40;</span>ISOComponent m, <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ISOException<span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> unpack <span style="color: #009900;">&#40;</span>ISOComponent m, <span style="color: #003399;">InputStream</span> in<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, ISOException<span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getFieldDescription<span style="color: #009900;">&#40;</span>ISOComponent m, <span style="color: #000066; font-weight: bold;">int</span> fldNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">public</span> ISOMsg createISOMsg <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>La <strong>otra manera es crear un empaquetado genérico</strong>, que no es mas que crear una estructura en XML donde indicamos, el <strong>id</strong>, el largo del mensaje, el <strong>nombre</strong>, y el <strong>tipo de dato</strong>, en ese campo vamos agregar <strong>la clase </strong>del tipo de dato que nos ofrece jPOS.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE isopackager SYSTEM &quot;genericpackager.dtd&quot;&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- ISO 8583:1993 (BINARY) field descriptions for GenericPackager --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Message Type Indicator&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">pad</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFB_NUMERIC&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">      <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;16&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Bitmap&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFB_BITMAP&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    ...
    ...
    ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isofield</span></span>
<span style="color: #009900;">        <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;128&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;8&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Message authentication code field&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.IFB_BINARY&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/isopackager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Si <a href="http://sourceforge.net/projects/jpos/files/jpos/1.6.4/jpos-1.6.4.zip/download">descargas jPOS</a>, podrás encontrar listos y para su uso algunos ejemplos en la ubicación <strong>cfg/packager</strong>.</p>
<p><strong>Nota</strong>: Debes tener en cuenta que el <strong>genericpackager.dtd</strong> y el <strong>generic-validating-packager.dtd </strong>deben estar en el mismo directorio y tener <strong>permisos de lectura</strong> (linux) para que el paquete genérico pueda leer la configuración creada por vos.</p>
<p>Una vez listo tenemos nuestro xml para el empaquetador genérico, que se adapte a nuestras necesidades solo agregamos el PATH como parametro del constructor de la clase <strong>GenericPackager</strong> y listo para usarse como en el <a href="http://blog.jotadeveloper.com/2009/07/07/jpos-y-el-echo-test-0800/">siguiente ejemplo</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;miPaquetePersonalizado.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Una vez cargada la configuración, ya podemos empaquetar y<strong> tendremos lista nuestra trama para enviarla por el socket.</strong> o si desempaquetamos, <strong>el canal que usemos se encargará de converir la trama en un objeto ISOMsg.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Para reempaquetar</span>
iso.<span style="color: #006633;">recalcBitMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//o usar los métodos para empaquetar</span>
iso.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//o</span>
<span style="color: #666666; font-style: italic;">// Para desempaquetar</span>
iso.<span style="color: #006633;">unpack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/07/30/paquetes-genericos-en-jpos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jPOS y el Echo Test 0800</title>
		<link>http://blog.jotadeveloper.com/2009/07/07/jpos-y-el-echo-test-0800/</link>
		<comments>http://blog.jotadeveloper.com/2009/07/07/jpos-y-el-echo-test-0800/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 15:37:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[0800]]></category>
		<category><![CDATA[echo test]]></category>
		<category><![CDATA[iso8583]]></category>
		<category><![CDATA[jpos]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2430</guid>
		<description><![CDATA[Continuando y aprendiendo mas sobre el Standard ISO8583 y jPOS, del cual hemos hablado anteriormente en otras entradas, hemos hablado de la mensajeria utilizada para el intercambio de transacciones entre sistemas por medio de un flujo de comunicacion. Hoy le toca el turno a otro tipo de mensaje que viene en este paquete del Standard [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/uploads/2009/07/credit_cards1.jpg" rel="lightbox"><img class="alignnone size-full wp-image-2435" title="credit_cards" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/07/credit_cards1.jpg" alt="credit_cards" width="425" height="224" /></a></p>
<p>Continuando y aprendiendo <a href="http://blog.jotadeveloper.com/2009/01/25/conociendo-el-standard-iso8583/">mas sobre el Standard ISO8583</a> y <a href="http://blog.jotadeveloper.com/2009/01/22/que-es-jpos/">jPOS</a>, del cual hemos hablado anteriormente en otras entradas, hemos hablado de la<a href="http://blog.jotadeveloper.com/2009/03/10/crear-mapa-de-bits-primario-y-secundario-en-jpos/"> mensajeria utilizada para el intercambio de transacciones</a> entre sistemas por medio de un flujo de comunicacion. <strong>Hoy le toca el turno a otro tipo de mensaje que viene en este paquete del Standard como es el de manejo de red e intercambio de claves.</strong></p>
<p>Este tipo de Mensaje, <strong>mejor conocido como</strong> <strong>0800 </strong>es<span style="text-decoration: underline;"> utilizado para mensajeria de Manejo de R</span><span style="text-decoration: underline;">ed</span>, siendo uno de los mas utilizados la mensajeria para enviar un <strong>Echo Test</strong>.</p>
<p>Una  vez que vez la terminal u origen de la transaccion basada en una tarjeta establezca comunicación con el emisor o procesador de la misma ,<strong> es necesario cuidar esta linea que une ambos sistemas</strong>, siendo esto uno de  los puntos centrales e importantes,<strong> se requiere  que esta comunicación  siempre este disponible</strong>.</p>
<p><strong>Y como hacemos esto cuando ambos sistemas se comunican por medio de mensajes y un standard?</strong></p>
<p>Facil tambien se pensó en esto, y es por eso que existe <strong>la mensajeria 0800</strong> en la cual podemos <strong>enviar constamente cada cierto periodo</strong> de tiempo un mensaje pequeño pero no menos importante <strong>cuya principal funcion es que ese canal que se ha abierto se mantenga asi las 24 horas y los 375 dias del año</strong>, que este habil y disponible para cuando una transaccion se desee realizar, y de esta manera nos evitariamos un sin numero de problemas.</p>
<p>Un ejemplo de un mensaje echo test seria lo siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ISOMsg msgiso <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ISOMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Importante el encabezado 800,</span>
<span style="color: #003399;">String</span> mti <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0800&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Si tu  mensaje lleva header aqui se pone la cadena de texto</span>
<span style="color: #003399;">String</span> header <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;tuHeader&quot;</span><span style="color: #339933;">;</span>
msgiso.<span style="color: #006633;">setMTI</span><span style="color: #009900;">&#40;</span>mti<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Agregamos el Header del mensaje si lo necesitamos, el header se tiene que guardar en bytes</span>
BaseHeader db <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BaseHeader<span style="color: #009900;">&#40;</span>header .<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
msgiso.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span>db<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Campo 7, con ISODate obtenemos la fecha en formato ISO8583</span>
msgiso.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ISOField<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span>, ISODate.<span style="color: #006633;">getDateTime</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Campo 11, con ISOUtil.zeropad, rellenamos de ceros</span>
msgiso.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ISOField<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">11</span>, ISOUtil.<span style="color: #006633;">zeropad</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;555555&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Campo 70, el 301 por defecto</span>
msgiso.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ISOField<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">70</span>, <span style="color: #0000ff;">&quot;301&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Lo empaquetamos, generico o echo a la medida, tu eliges.</span>
GenericPackager packager <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenericPackager<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;miPaquetePersonalizado.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Empaquetamos el mensake</span>
msgiso.<span style="color: #006633;">setPackager</span><span style="color: #009900;">&#40;</span>packager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Construimos el BitMap</span>
msgiso.<span style="color: #006633;">recalcBitMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>El Echo test utiliza 3 campos fundamentales del ISO 8583</p>
<ul>
<li><strong>Campo 7:</strong> Formato: MMDDhhmmss, MM para el Mes, DD para los Dias, hh las horas, mm minutos y ss segundos.</li>
<li><strong>Campo 11:</strong> Número único generado por el sistema que envía el mensaje y es utilizado  para hacer corresponder las respuestas con los mensajes originales </li>
<li><strong>Campo 70:</strong> Este campo es por defecto <strong>301</strong>. Tambíen se usa el 001 para Logon, y el 002 para Logoff, pero en nuestro caso es 301. </li>
</ul>
<p><strong>Conclusión</strong>, como pudiste ver, es bien sencillo construir un echo test, es un mensaje muy sencillo, que generalmente se envia cada cierto tiempo, suele ser una vez cada 30 o 45 minutos, <strong>depende la procesadora de tarjetas de crédito lo requiera</strong>, se puede usar un ciclo en el Q2 o construir tu propia interfaz externa que se comunique con el Q2 para canalizar los echo test.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/07/07/jpos-y-el-echo-test-0800/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Twitter con jPOS? Esto si que es innovación !!</title>
		<link>http://blog.jotadeveloper.com/2009/06/12/twitter-con-jpos-esto-si-que-es-innovacion/</link>
		<comments>http://blog.jotadeveloper.com/2009/06/12/twitter-con-jpos-esto-si-que-es-innovacion/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 17:07:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[jpos]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1858</guid>
		<description><![CDATA[Tal vez una de las fusiones más raras que he visto de una comunidad social con un framework sobre transacciones bancarias, esta clase la encontre en el grupo de jPOS y la verdad como Twittero, me dejo algo alucinado. Actualización 18/06/09 La única utilidad que le veo es que los log del SysLog del Q2Server [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/uploads/2009/06/jPOSTwitter1.jpg" rel="lightbox"><img class="alignnone size-full wp-image-1861" title="jPOSTwitter" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/06/jPOSTwitter1.jpg" alt="jPOSTwitter" width="830" height="360" /></a></p>
<p>Tal vez una de las <strong>fusiones más raras que he visto de una comunidad social con un framework sobre transacciones bancarias</strong>, esta clase la encontre en el grupo de jPOS y la verdad como Twittero,<strong> me dejo algo alucinado</strong>.</p>
<h3>Actualización 18/06/09</h3>
<p>La única <strong>utilidad</strong> que le veo es que los log del SysLog del Q2Server aparecen como nuevos mensajes en tu cuenta de  Twitter , <a href="http://groups.google.com/group/jpos-users/browse_thread/thread/9473f75903a8d594/988f4b22d54d32a8?lnk=gst&amp;q=twitter#988f4b22d54d32a8">ha sido probado y funciona</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * jPOS Project [http://jpos.org]
 * Copyright (C) 2000-2008 Alejandro P. Revilla
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">org.jpos.util</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Locale</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.SimpleDateFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.core.Configurable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.core.Configuration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.core.ConfigurationException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.q2.Q2</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">winterwell.jtwitter.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Twitter Listener
 *
 *  requires jtwitter.jar from http://www.winterwell.com/software/jtwitter.php
 *
 *  Sample configuration:
 *
 *  &lt;log-listener class=&quot;org.jpos.util.TwitterLogListener&quot;&gt;
 *     &lt;property name=&quot;twitterUsername&quot; value=&quot;paymentsystems&quot; /&gt;
 *     &lt;property name=&quot;twitterPassword&quot; value=&quot;SuperSecretPassword&quot; /&gt;
 *     &lt;property name=&quot;tags&quot; value=&quot;twitter&quot; /&gt;
 *     &lt;property name=&quot;prefix&quot; value=&quot;[jPOS]&quot;/&gt;
 *  &lt;/log-listener&gt;
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TwitterLogListener <span style="color: #000000; font-weight: bold;">implements</span> LogListener, Configurable <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Configuration   cfg<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>          twitterUsername<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>          twitterPassword<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>          prefix<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>          tags<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span>          twitterMessage<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span>             MAX_MESSAGE_SIZE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">140</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> TwitterLogListener <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> LogEvent log <span style="color: #009900;">&#40;</span>LogEvent ev<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ev.<span style="color: #006633;">tag</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> tags.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>ev.<span style="color: #006633;">tag</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            Twitter twitter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Twitter<span style="color: #009900;">&#40;</span>twitterUsername,twitterPassword<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            StringBuilder sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>prefix <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                sb.<span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span>prefix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                sb.<span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #003399;">Iterator</span> iter <span style="color: #339933;">=</span> ev.<span style="color: #006633;">payLoad</span>.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> iter.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
                    sb.<span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    sb.<span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span>iter.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span>MAX_MESSAGE_SIZE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                twitterMessage <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,MAX_MESSAGE_SIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                twitterMessage <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                twitter.<span style="color: #006633;">updateStatus</span><span style="color: #009900;">&#40;</span>twitterMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>TwitterException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                ev.<span style="color: #006633;">addMessage</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;--- TwitterLogListener error ---&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                ev.<span style="color: #006633;">addMessage</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> ev<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setConfiguration <span style="color: #009900;">&#40;</span>Configuration cfg<span style="color: #009900;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">ConfigurationException</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">cfg</span> <span style="color: #339933;">=</span> cfg<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            twitterUsername <span style="color: #339933;">=</span> cfg.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;twitterUsername&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            twitterPassword <span style="color: #339933;">=</span> cfg.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;twitterPassword&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            tags     <span style="color: #339933;">=</span> cfg.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tags&quot;</span>, <span style="color: #0000ff;">&quot;twitter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            prefix <span style="color: #339933;">=</span> cfg.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prefix&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ConfigurationException</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/06/12/twitter-con-jpos-esto-si-que-es-innovacion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listeners en jPOS, el ISORequestListener con QMUX</title>
		<link>http://blog.jotadeveloper.com/2009/06/12/listeners-en-jpos-el-isorequestlistener-con-qmux/</link>
		<comments>http://blog.jotadeveloper.com/2009/06/12/listeners-en-jpos-el-isorequestlistener-con-qmux/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 16:18:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[ISORequestListener]]></category>
		<category><![CDATA[jpos]]></category>
		<category><![CDATA[QMUX]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1835</guid>
		<description><![CDATA[Te preguntaras, que es jPOS?, aquí la respuesta. Cuando usas tu tarjeta de crédito, jPOS es usado en la mayoria de los interfaces para las transacciones de Tarjetas de Crédito, pues es un Framework muy usado y extendido para el protocolo ISO 8583, lo mejor, es gratis. jPOS ofrece un servidor, llamado Q2 Server, donde [...]]]></description>
			<content:encoded><![CDATA[<p>Te preguntaras, <strong>que es jPOS?</strong>, <a href="http://blog.jotadeveloper.com/2009/01/22/que-es-jpos/">aquí la respuesta</a>.  Cuando usas  tu<strong> tarjeta de crédito</strong>, jPOS es usado en la mayoria de los interfaces para las transacciones de Tarjetas de Crédito, pues es un Framework muy usado y extendido para el <a href="http://blog.jotadeveloper.com/2009/01/25/conociendo-el-standard-iso8583/">protocolo ISO 8583</a>, lo mejor, es gratis.</p>
<p>jPOS ofrece un servidor, llamado <a href="http://blog.jotadeveloper.com/2009/03/11/construyendo-un-q2-server-en-jpos/">Q2 Server</a>, donde podemos montar un proceso intermedio entre tu sistema y tu procesadora de tarjetas de crédito. Cuando estamos trabajando a <strong>nivel empresarial</strong>, donde las transacciones <strong>se hacen en segundos</strong> y es necesario dos caracteristicas que nos ofrece jPOS, el QMUX y el ISORequestListener.</p>
<p>El <strong>ISORequestListener</strong>, este <a href="http://www.jpos.org/doc/javadoc/org/jpos/iso/ISORequestListener.html" target="_blank">interfaz </a>sirve para construir nuestros propios  Listeners y así poder integrarlos con un multiplexor QMUX, el Listener escuchará todas las peticiones de transacciones entrantes y salientes y las procesara según lo que necesites, en nuestro caso, las mandaremos a un multiplexor y esperara una respuesta, con esto podemos controlar errores o personalizar los mensajes de respuesta según nuestras necesidades.</p>
<p>El <strong>QMUX, </strong>el multiplexor, como su definición indica,  se utiliza como dispositivo que puede recibir varias entradas y transmitirlas por un <a style="text-decoration: none; color: #002bb8; background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; background-position: initial initial;" title="Medio de transmisión" href="http://es.wikipedia.org/wiki/Medio_de_transmisi%C3%B3n">medio de transmisión</a> compartido. Para ello lo que hace es dividir el medio de transmisión en múltiples <a style="text-decoration: none; color: #002bb8; background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; background-position: initial initial;" title="Canal de comunicaciones" href="http://es.wikipedia.org/wiki/Canal_de_comunicaciones">canales</a>, para que varios nodos puedan comunicarse al mismo tiempo.</p>
<p><a href="http://blog.jotadeveloper.com/wp-content/uploads/2009/06/IsoRequestListener21.jpg" rel="lightbox"><img class="alignnone size-full wp-image-1843" title="IsoRequestListener" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/06/IsoRequestListener21.jpg" alt="IsoRequestListener" width="560" height="227" /></a></p>
<p>Vamos a <strong>explicar la figura</strong>, muchas aplicaciones se comunican con el Q2 server, el Q2 ejecuta la lógica del ISORequestListener personalizado y busca el QMUX e el jPOS Space, <strong>podemos tener muchos multiplexores</strong>, en nuestro caso solo tenemos uno y lo buscamos por el nombre identificador. E<strong>l Adaptador ISO8583 se encarga de la conexión con la Empresa Procesadora de Tarjeta</strong>s, esto lo veremos en otro artículo, cuando la primera parte del ciclo se concreta, la Empresa entrega una respuesta al Adaptador, el Adaptador al QMUX y el ISORequestListener espera la respuesta de la petición, <strong>el Listener buscará en el jPOS Space tu transacción por un campo clave</strong>, generalmente el campo 11 del ISO 8583, y así termina el ciclo.</p>
<p>El ISORequestListener se configura en el Q2Server de una manera muy sencilla.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;server</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;xml-server&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.q2.iso.QServer&quot;</span> <span style="color: #000066;">logger</span>=<span style="color: #ff0000;">&quot;Q2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attr</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;port&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;java.lang.Integer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>8000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/attr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dummyclient.channel&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.channel.BASE24Channel&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">packager</span>=<span style="color: #ff0000;">&quot;org.jpos.iso.packager.GenericPackager&quot;</span> <span style="color: #000066;">logger</span>=<span style="color: #ff0000;">&quot;Q2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;packager-config&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;cfg/packager/base24.xml&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- Solo agregamos esta línea a la configuración de nuestro Q2 Server --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;request-listener</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;mipaquete.MiListenerPersonalizado&quot;</span> <span style="color: #000066;">logger</span>=<span style="color: #ff0000;">&quot;Q2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>El ISORequestListener puede programarse de una manera básica de las siguiente manera</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISODate</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOMsg</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISORequestListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOSource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.ISOUtil</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.iso.header.BaseHeader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.q2.iso.QMUX</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.util.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jpos.util.NameRegistrar</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* http://blog.jotadeveloper.com
*Creado por JotaDeveloper
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MiListenerPersonalizado <span style="color: #000000; font-weight: bold;">extends</span> Log <span style="color: #000000; font-weight: bold;">implements</span> ISORequestListener <span style="color: #009900;">&#123;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> process<span style="color: #009900;">&#40;</span>ISOSource source, ISOMsg m<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ISOMsg responseISOMsg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		QMUX mux <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//Buscamos en el jPOS Space nuestro multiplextor, siempre se busca con el prefijo mux seguido por un punto</span>
			mux <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>QMUX<span style="color: #009900;">&#41;</span> NameRegistrar.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mux.mymux&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			mux.<span style="color: #006633;">setLogger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mux&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//Se recupera la respuesta</span>
			responseISOMsg <span style="color: #339933;">=</span> mux.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span>m, <span style="color: #cc66cc;">20000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>NameRegistrar.<span style="color: #006633;">NotFoundException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ISOException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">//Es importante siempre regresar true.</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y el multiplexor se configura con XML, pues el QMUX ya viene programador por defecto</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mux</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jpos.q2.iso.QMUX&quot;</span> <span style="color: #000066;">logger</span>=<span style="color: #ff0000;">&quot;Q2&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mymux&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;in<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sample-receive<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/in<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;out<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sample-send<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/out<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- Este key, es la llave por la cual identificaras unicamente cada mensaje, es importante</span>
<span style="color: #808080; font-style: italic;">poner el valor indicado, generalmente es el 11 o el 17 --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>55<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mux<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>En el próximo artículo, veremos los adaptadores y los diferentes tipos de conexiones que podemos crear con jPOS.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/06/12/listeners-en-jpos-el-isorequestlistener-con-qmux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
