devexpress pdf viewer asp.net mvc : Convert multiple pdf to jpg SDK Library service wpf asp.net winforms dnn Enterprise-Development-with-Flex25-part722

but not confirmed messages into yet another property of the 
ClientHeartbeatMessage
;
it’s called 
received
and has the type 
Array
(Example 5-10).
Example 5-9. AcknowledgingChannel.as
package com.farata.messaging.channels {
import com.farata.messaging.messages.ReliableServerMessage;
import flash.utils.Dictionary;
import mx.messaging.channels.RTMPChannel;
import mx.messaging.messages.IMessage;
public class AcknowledgingRTMPChannel extends
mx.messaging.channels.RTMPChannel   {
public function AcknowledgingRTMPChannel(
id:String=null, uri:String=null)   {
super(id, uri);
}
override public function receive(
msg:IMessage, ...rest:Array) : void {
if (msg is ReliableServerMessage) {
var seqNo : Number = Number(msg.headers["seqNo"]);
received.push( msg.clientId + "|"+ seqNo);
}
super.receive( msg, rest);
}
public static function getConfirmations(result:Array):Array {
if (result == null) result = [];
for (var i:int=0;  i < received.length; i++) {
result.push(received[i]);
}
received=[];
return result;
}
private static var received:Array=[];
}
}
Next come the ActionScript and Java versions of the 
ClientHeartbeatMessage
(Exam-
ple 5-10). The ActionScript class has been upgraded from Example 5-1 to populate the
received
array.
Example 5-10. ClientHeartbeatMessage.as and ClientHeartbeatMessage.java
package com.farata.messaging.messages{
import com.farata.messaging.channels.AcknowledgingRTMPChannel;
import mx.messaging.messages.AbstractMessage;
public  class ClientHeartbeatMessage extends
mx.messaging.messages.AbstractMessage{
public var received:Array;
public function ClientHeartbeatMessage() {
Building a Custom Acknowledging Channel l | | 227
Convert multiple pdf to jpg - Convert PDF to JPEG images in C#.net, ASP.NET MVC, WinForms, WPF project
How to convert PDF to JPEG using C#.NET PDF to JPEG conversion / converter library control SDK
changing file from pdf to jpg; best convert pdf to jpg
Convert multiple pdf to jpg - VB.NET PDF Convert to Jpeg SDK: Convert PDF to JPEG images in vb.net, ASP.NET MVC, WinForms, WPF project
Online Tutorial for PDF to JPEG (JPG) Conversion in VB.NET Image Application
c# convert pdf to jpg; batch convert pdf to jpg online
super();
received = AcknowledgingRTMPChannel.getConfirmations();
}
}
}
package com.farata.messaging.messages;
import flex.messaging.messages.AbstractMessage;
public class ClientHeartbeatMessage extends AbstractMessage {
public String[] processed;
public String[] received;
}
Resending Messages with QoSAdapter
We have completed the first half of the exercise, in which the heartbeats travel with
delivery confirmations via the 
AcknowledgingRTMPChannel
. The other half of the solution
is:
• To accumulate the delivery confirmations coming from the client with each heart-
beat. This will be done in the QoSAdapter.java adapter.
• Upon certain timeout, resend unconfirmed messages to the client. This task
requires an additional Java 
resender
thread, started in QoSAdapter.java.
To figure out on the server which messages were confirmed, we need to keep all un-
confirmed messages in a safe place—the 
unconfirmedMessageMap
in the 
QoSAdapter
:
static {
unconfirmedMessageMap =
new ConcurrentHashMap<String, ReliableServerMessage>();
}
The data type of this Java map is 
ConcurrentHashMap
, which is a 
HashMap
that supports
concurrent data updates; this is essential in situations in which confirmations can arrive
from multiple clients but will all be stored in the same map.
Accordingly, in Example 5-11, the 
invoke()
method puts every 
Reliable
ServerMessage
into the map via a 
registerForDeliveryConfirmation()
call.
We also want to emulate the loss of messages on the server by marking about 20 percent
(the function 
Math.random()
takes care of it) with the header property 
tm
for “test mode.”
Example 5-11. Method invoke() of QoSAdapter.java
public Object invoke(Message message){
isDebug = logger.isDebugEnabled();
if ( message instanceof ReliableServerMessage ) {
registerForDeliveryConfirmation((ReliableServerMessage)message);
double random = Math.random();
228 | | Chapter 5: Customizing the Messaging Layer of LCDS or BlazeDS
C# Create PDF from images Library to convert Jpeg, png images to
Batch convert PDF documents from multiple image formats, including Jpg, Png, Bmp, Gif, Tiff, Bitmap, .NET Graphics, and REImage.
convert pdf into jpg; .pdf to jpg converter online
VB.NET Create PDF from images Library to convert Jpeg, png images
Components to batch convert PDF documents in Visual Basic .NET class. Support create PDF from multiple image formats in VB.NET, including Jpg, Png, Bmp, Gif
convert pdf pages to jpg online; convert pdf file into jpg format
if ((random<0.2) && (String)message.getHeader("tm")!=null) {
String seqNo = (String)message.getHeader("seqNo");
if (isDebug) logger.debug(
"QoS adapter emulating loss of message " + seqNo
);
} else {
sendToClient((ReliableServerMessage)message);
}
} else if ( message instanceof ClientHeartbeatMessage ) {
processDeliveryConfirmations((ClientHeartbeatMessage) message);
}
return null;
}
The complete listing of QoSAdapter.java is presented in Example 5-12. The method
registerForDeliveryConfirmation()
adds messages to the map using 
clientId +
"|"+sequenceNumber
digest as a key, which matches the format in which
AcknowledgingChannel
prepares delivery confirmations. Accordingly, the
processDeliveryConfirmation()
call removes the records from the map.
Both methods lock access to the map with the 
synchronized(unconfirmedMessageMap)
Java keyword, not to race with each other but rather to coordinate concurrent access
between 
QoSAdapter
and the auxiliary 
Resender
thread.
Example 5-12. QoSAdapter.java—a resending adapter
package com.farata.messaging.adapter;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Logger;
import com.farata.messaging.messages.ClientHeartbeatMessage;
import com.farata.messaging.messages.ReliableServerMessage;
import flex.messaging.config.ConfigMap;
import flex.messaging.messages.Message;
import flex.messaging.services.MessageService;
import flex.messaging.services.messaging.adapters.MessagingAdapter;
public class QoSAdapter extends MessagingAdapter {
public void initialize(String id, ConfigMap properties){
super.initialize(id, properties);
if( resender == null) {
resender = new Resender();
Thread resenderThread =   new Thread(resender, "Resender");
resenderThread.setDaemon(true);
resenderThread.start();
}
}
Resending Messages with QoSAdapter r | 229
C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP.
Free online C#.NET source code for combining multiple PDF pages together in .NET framework. Combine scanned images to PDF, such as tiff, jpg, png, gif, bmp
convert pdf into jpg online; bulk pdf to jpg converter
C# WPF PDF Viewer SDK to convert and export PDF document to other
Create multiple pages Tiff file from PDF document. Convert PDF to image file formats with high quality, support converting PDF to PNG, JPG, BMP and GIF.
change from pdf to jpg; change pdf to jpg
public Object invoke(Message message){
isDebug = logger.isDebugEnabled();
if ( message instanceof ClientHeartbeatMessage ) {
} else if ( message instanceof ReliableServerMessage ) {
double random = Math.random();
String seqNo = (String)message.getHeader("seqNo");
if (isDebug) logger.debug(
"QoS adapter emulating loss of message " + seqNo
);
} else {
sendToClient((ReliableServerMessage)message);
}
}
return null;
}
String clientId = (String)message.getClientId();
String seqNo = (String)message.getHeader("seqNo");
synchronized(unconfirmedMessageMap) {
message.setHeader("registeredTs", System.currentTimeMillis());
unconfirmedMessageMap.put(clientId + "|" + seqNo, message);
}
}
private void sendToClient(ReliableServerMessage message) {
String seqNo = (String)message.getHeader("seqNo");
String clientId = (String)message.getClientId();
MessageService msgService = (MessageService)getDestination().
getService();
if (isDebug) logger.debug(
"QoS adapter is sending through message " + seqNo
);
Set<String> subscriberIds = new HashSet<String>();
subscriberIds.add(clientId);
msgService.pushMessageToClients(subscriberIds, message, false);
}
if ((message.received!=null) && (message.received.length>0)) {
if (isDebug) logger.debug(
"QoS adapter received delivery confirmations:"
);
synchronized(unconfirmedMessageMap) {
for (int i=0; i <message.received.length; i++) {
if (isDebug) logger.debug(
"...and removes (CLIENTID|seqNo)" + message.received[i]
);
unconfirmedMessageMap.remove(message.received[i]);
}
230 | | Chapter 5: Customizing the Messaging Layer of LCDS or BlazeDS
C# PDF Convert to Images SDK: Convert PDF to png, gif images in C#
An advanced .NET control able to batch convert PDF documents to image formats in C#.NET. Support exporting PDF to multiple image forms, including Jpg, Png, Bmp
convert pdf to jpg for; convert pdf file into jpg
VB.NET PDF File Merge Library: Merge, append PDF files in vb.net
Combine multiple specified PDF pages in into single one file. VB.NET Components to combine various scanned images to PDF, such as tiff, jpg, png, gif, bmp
.pdf to .jpg online; convert pdf pictures to jpg
}
}
}
private boolean isDebug;
private Resender resender = null;
static public ConcurrentHashMap<String, ReliableServerMessage>
unconfirmedMessageMap;
static Logger logger;
static {
unconfirmedMessageMap = new ConcurrentHashMap<String,
ReliableServerMessage>();
logger = Logger.getLogger(QoSAdapter.class);
}
}
The code in Example 5-12 uses the class 
MessageService
, which manages point-to-point
and publish/subscribe messaging. Specifically, 
QoSAdapter
uses it to push messages to
clients.
The 
Resender
thread wakes up every 500 milliseconds and removes all messages that
are 20 seconds old from the “unconfirmed” map. For remaining messages that are
sitting in the map for as long as three seconds, 
Resender
sends another copy of these
messages:
MessageBroker mb = MessageBroker.getMessageBroker(null);
mb.routeMessageToService(message, null);
Example 5-13 presents the 
Resender
thread.
Example 5-13. Example of the module
package com.farata.messaging.adapter;
import com.farata.messaging.messages.ReliableServerMessage;
import flex.messaging.MessageBroker;
import java.util.Enumeration;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Logger;
public class Resender implements Runnable {
public static int RESENDER_THREAD_SLEEP = 500;
public static int RESEND_TIMEOUT = 3000; //Resend after 3 sec
public static int DEAD_CLIENT_TIMEOUT = 20000; //Remove after 20 sec
protected static Resender resender = null;
public void run() {
ConcurrentHashMap<String, ReliableServerMessage> map =
QoSAdapter.unconfirmedMessageMap;
while (true) {
try {
Thread.sleep(RESENDER_THREAD_SLEEP);
synchronized (map) {
Resending Messages with QoSAdapter r | 231
C# Create PDF Library SDK to convert PDF from other file formats
Gratis control for creating PDF from multiple image formats such as tiff, jpg, png, gif, bmp, etc. Create writable PDF from text (.txt) file.
convert multiple pdf to jpg online; convert pdf to 300 dpi jpg
VB.NET PDF Convert to Images SDK: Convert PDF to png, gif images
PDF. Convert PDF documents to multiple image formats, including Jpg, Png, Bmp, Gif, Tiff, Bitmap, .NET Graphics, and REImage. Turn
change pdf file to jpg file; convert multi page pdf to jpg
String key = e.nextElement();
ReliableServerMessage message = map.get(key);
String seqNo = (String)message.getHeader("seqNo");
long nowTs=System.currentTimeMillis();
long createdTs = message.getTimestamp();
if ((nowTs - createdTs) > DEAD_CLIENT_TIMEOUT) {
if (logger.isDebugEnabled())logger.debug(
"Resender thread deletes message  " + seqNo
);
map.remove(key);
} else if ((nowTs - registeredTs) > RESEND_TIMEOUT) {
if (logger.isDebugEnabled())logger.debug(
"Resender thread resends message " + seqNo
);
mb.routeMessageToService(message, null);
}
} //for
} //synchronized
} catch (InterruptedException ex){
if (logger.isInfoEnabled()) logger.info(
"..in Resender......Interrupted"
);
}
} //while
}
static Logger logger;
static{
logger = Logger.getLogger(Resender.class);
}
}
Wondering where the message gets timestamped with the 
registeredTs
header? After
the 
routeMessageToService(message, null)
call, the message will be caught by the
QoSAdapter
QoSAdapter
will replace the old incarnation of the message in the map and
then send the message to the client only with 80 percent probability (if the 
tm
header
is not null).
Testing Guaranteed Delivery
All the pieces are ready to guarantee that every 
ReliableServerMessage
will get delivered
to the client. Before testing it, however, specify the acknowledging channel in services-
config.xml with the code in Example 5-14.
232 | | Chapter 5: Customizing the Messaging Layer of LCDS or BlazeDS
Example 5-14. Registering custom AcknowledgingChannel
<channel-definition id="my-acknowledging-client-rtmp"
class="com.farata.messaging.channels.AcknowledgingRTMPChannel">
<endpoint uri="rtmp://{server.name}:2040"
class="flex.messaging.endpoints.RTMPEndpoint"/>
<properties>
<idle-timeout-minutes>20</idle-timeout-minutes>
</properties>
</channel-definition>
In messaging-config.xml, we direct the custom 
QoSAdapter
to intercept messages coming
both to 
clientHeartbeat
and 
serverDeliveryTest
destinations (Example 5-15).
Example 5-15. Configuring destinations for the No Server Message Left Behind test
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition
id="actionscript" default="true"
class="flex.messaging.services.messaging.adapters.
ActionScriptAdapter"/>
<adapter-definition id="jms"
class="flex.messaging.services.messaging.adapters.
JMSAdapter"/>
<adapter-definition
id="qos"
class="com.farata.messaging.adapter.QoSAdapter"/>
</adapters>
<default-channels>
<channel ref="my-rtmp" />
</default-channels>
<destination id="clientHeartbeat">
<adapter ref="qos"/>
<channels>
<channel ref="my-rtmp" />
</channels>
</destination>
<destination id="serverDeliveryTest">
<adapter ref="qos"/>
<channels>
<channel ref="my-acknowledging-client-rtmp" />
</channels>
</destination>
</service>
Testing Guaranteed Delivery y | | 233
Once we are done with the messaging configurations, let’s look at the Java application
class, 
ServerMessagingTest
, that we will remote to in order to run the test interactively
(Example 5-16). The method 
testDeliveryFailure()
sends 
messageCount
number of
messages sequentially enumerated via the 
seqNo
header with 
start
as the offset.
Example 5-16. ServerMessagingTest class
package com.farata.test;
import java.util.ArrayList;
import com.farata.messaging.messages.ReliableServerMessage;
import flex.messaging.MessageBroker;
public class ServerMessagingTest {
private static MessageBroker mb;
private void send(ReliableServerMessage message) {
if (mb == null) {
mb = MessageBroker.getMessageBroker(null);
}
mb.routeMessageToService(message, null);
}
public void testDeliveryFailure(String clientId, int start,
int messageCount) {
ReliableServerMessage message;
for (int i= 0; i < messageCount; i++) {
message = new ReliableServerMessage(
"Server message #"  + (i+start)
);
message.setHeader("testMode", "true");
message.setClientId(clientId);
message.setDestination("serverDeliveryTest");
message.setHeader("seqNo", "" + (i+start));
send(message);
}
}
// Other tests
}
To remote to this class, we will register it in the remoting-config.xml file:
<destination id="com.farata.test.ServerMessagingTest">
<properties>
<source>com.farata.test.ServerMessagingTest</source>
</properties>
</destination>
234 | | Chapter 5: Customizing the Messaging Layer of LCDS or BlazeDS
The Flex application TestServerDelivery will be used as a client portion of the testing
setup. This application, besides having an obligatory 
ClientHeartbeatProducer
, also
has a 
Consumer
that listens to the 
serverDeliveryTest
destination. Once a
ReliableServerMessage
arrives, the application displays it in the custom control
MessageBar
, as shown in Figure 5-6. The code of the application is presented in
Example 5-17; the code of the 
MessageBar
we omit for brevity. You can find it in the
sample source code accompanying the book.
Figure 5-6. Running the TestServerDelivery application
Example 5-17. The TestServerDelivery Flex application
<?xml version="1.0" encoding="utf-8"?>
<!--TestServerDelivery.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:fs="http://www.faratasystems.com/2009/components"
xmlns:local=" *"
layout="vertical" creationComplete="onCreationComplete()">
<mx:Form>
<mx:FormItem label="Messages to send:">
<mx:TextInput text="10" id="msgCount"/>
<mx:Button label="Run Test" click="runTest()"/>
</mx:FormItem>
<mx:FormItem label="Received:">
<local:MessageBar id="messageBar" />
</mx:FormItem>
</mx:Form>
<mx:Script>
<![CDATA[
import com.farata.messaging.qos.ClientHeartbeatProducer;
import com.farata.messaging.messages.ReliableServerMessage;
import mx.messaging.events.MessageEvent;
import mx.messaging.Consumer;
[Bindable] public var consumer:Consumer;
Testing Guaranteed Delivery y | | 235
private var clientHeartbeatProducer:ClientHeartbeatProducer;
private function onCreationComplete():void {
clientHeartbeatProducer = new ClientHeartbeatProducer();
clientHeartbeatProducer.startHeartbeat();
consumer = new Consumer();
consumer.destination = "serverDeliveryTest";
consumer.subscribe();
consumer.addEventListener(MessageEvent.MESSAGE, onMessage);
}
private function onMessage(event:MessageEvent):void {
var message:ReliableServerMessage = event.message as
ReliableServerMessage;
var seqNo:Number = Number(message.headers["seqNo"]);
}
private var start:Number=0;
private function runTest():void {
messageBar.clean();
var count:Number = Number(msgCount.text);
test.testDeliveryFailure(consumer.clientId, start, count);
start = start + count;
}
]]>
</mx:Script>
<mx:TraceTarget />
</mx:Application>
Figure 5-6 illustrates a specific run of the test, where the custom adapter “lost” message
#6, which caused the resender thread to resend it later. The corresponding log of the
Java server classes is shown in Figure 5-7.
When Message Order Matters
Our guaranteed server message delivery is neglecting the order of the messages, which
may be an important factor in some business applications. In wide area networks
(WANs), messages can be routed in any random way and arrive in any order.
If the order matters in your application, mark the messages with sequence numbers as
they get sent and hold on to the “premature” ones on the receiving end. This QoS
technique pertains to both server- and client-originated messages. First consider the
messages originated on the server; this workflow is shown in Figure 5-8.
236 | | Chapter 5: Customizing the Messaging Layer of LCDS or BlazeDS
Documents you may be interested
Documents you may be interested