Search Results

Search found 539 results on 22 pages for 'alan fietz'.

Page 3/22 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • spring mvc simpleformcontroller - how to stop execution when exception thrown

    - by alan t
    Hi I am using simpleformcontroller and get exception thrown in my OnSubmit method. This does not seem to stop the simpleformcontroler process as it redisplays my form. I can see from log4j output that the exception is getting caught and forwarding to my error page as expected. I can also tell the onSubmit method does not continue after the exception. Which is all good. But i do not see the error page as the simpleformcontroller starts up again and goes through processing for a new form (i can see in log4j ouput Spring log statements 'Displaying New form', 'Creating new command of class ..'. The normal form page is then displayed again. So the problem is that the exception does not seem to terminate the SimpleFormController, it carries on to display the form again. Anyone help? Thanks Alan

    Read the article

  • Email attachment problem

    - by Alan Harris-Reid
    Hi there, I want to send an email with an attachment using the following code (Python 3.1) (greatly simplified to show the example) from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText msg = MIMEMultipart() msg['From'] = from_addr msg['To'] = to_addr msg['Subject'] = subject msg.attach(MIMEText(body)) fp = open(att_file) msg1 = MIMEText(fp.read()) attachment = msg1.add_header('Content-Disposition', 'attachment', filename=att_file) msg.attach(attachment) # set string to be sent as 3rd parameter to smptlib.SMTP.sendmail() send_string = msg.as_string() The attachment object msg1 returns 'email.mime.text.MIMEText' object at ', but when the msg1.add_header(...) line runs the result is None, hence the program falls-over in msg.as_string() because no part of the attachment can have a None value. (Traceback shows "'NoneType' object has no attribute 'get_content_maintype'" in line 118 of _dispatch in generator.py, many levels down from msg.as_string()) Has anyone any idea what the cause of the problem might be? Any help would be appreciated. Alan Harris-Reid

    Read the article

  • CherryPy configuration tools.staticdir.root problem

    - by Alan Harris-Reid
    Hi there, How can I make my static-file root directories relative to my application root folder (instead of a hard-coded path)? In accordance with CP instructions (http://www.cherrypy.org/wiki/StaticContent) I have tried the following in my configuration file: tree.cpapp = cherrypy.Application(cpapp.Root()) tools.staticdir.root = cpapp.current_dir but when I run cherrpy.quickstart(rootclass, script_name='/', config=config_file) I get the following error builtins.ValueError: ("Config error in section: 'global', option: 'tree.cpapp', value: 'cherrypy.Application(cpapp.Root())'. Config values must be valid Python.", 'TypeError', ("unrepr could not resolve the name 'cpapp'",)) I know I can do configuration from within the main.py file just before quickstart is called (eg. using os.path.abspath(os.path.dirname(file))), but I prefer using the idea of a separate configuration file if possible. Any help would be appreciated (in case it is relevant, I am using CP 3.2 with Python 3.1) TIA Alan

    Read the article

  • Build warning for distribution configuration of an iPad only application

    - by alan
    Hi, I'm getting the following warning when building an ad hoc distribution copy of a new iPad only application: [BWARN]warning: building with 'Targeted Device Family' that includes iPad ('2') requires building with the 3.2 or later SDK. These are my build settings: Architectures: Optimized (armv6 armv7) Any iPhone OS Simulator: i386 Any iPhone OS Device: Optimized (armv6 armv7) Base SDK: iPhone Device 3.2 Valid Architectures: armv6 armv7 Target Device Family: iPad iPhone OS Deployment Target: iPhone OS 3.2 With this in mind I don't understand the warning. It seems to build and run OK but I'd rather not have warnings in my build for obvious reasons. Any ideas? Thanks in advance, Alan.

    Read the article

  • Multi-part template issue with Jinja2

    - by Alan Harris-Reid
    Hi, When creating templates I typically have 3 separate parts (header, body, footer) which I combine to pass a singe string to the web-server (CherryPy in this case). My first approach is as follows... from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('')) tmpl = env.get_template('Body.html') page_body = tmpl.render() tmpl = env.get_template('Header.html') page_header = tmpl.render() tmpl = env.get_template('Footer.html') page_footer = tmpl.render() page_code = page_header + page_body + page_footer but this contains repetitious code, so my next approach is... def render_template(html_file): from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('')) tmpl = env.get_template(html_file) return tmpl.render() page_header = render_template('Header.html') page_body = render_template('Body.html') page_footer = render_template('Footer.html) However, this means that each part is created in its own environment - can that be a problem? Are there any other downsides to this approach? I have chosen the 3-part approach over the child-template approach because I think it may be more flexible (and easier to follow), but I might be wrong. Anyone like to convince me that using header, body and footer blocks might be better? Any advice would be appreciated. Alan

    Read the article

  • Navigating cursor rows in SQLite

    - by Alan Harris-Reid
    Hi there, I am trying to understand how the following builtin functions work when sequentially processing cursor rows. The descriptions come from the Python 3.1 manual (using SQLite3) Cursor.fetchone() Fetches the next row of a query result set, returning a single sequence. Cursor.fetchmany() Fetches the next set of rows of a query result, returning a list. Cursor.fetchall() Fetches all (remaining) rows of a query result, returning a list. So if I have a loop in which I am processing one row at a time using cursor.fetchone(), and some later code requires that I return to the first row, or fetch all rows using fetchall(), how do I do it? The concept is a bit strange to me, especially coming from a Foxpro background which has the concept of a record pointer which can be moved to the 1st or last row in a cursor (go top/bottom), or go to the nth row (go n) Any help would be appreciated. Alan

    Read the article

  • onTextChanged Event for many Textboxes c#

    - by Alan Bennett
    Hi, I am currently building a prototype for a new system screen, and i am using c# to build this. The question i have is, i currently have 14 textboxes which are filled from a condition from a couple of other controls on the screen. these 14 textboxes all add up to a total shown in another textbox. as these textboxes are editable (in case the client wishes to increase the value) (cant go into to much detail but they will) I need to have a firable ontextchange event for when the values change so the total box updates. however i have a feeling there must be a way of not having to create 14 different events, is there a way that i can have 1 event which fires if any of the 14 text boxes are fired? thanks Alan

    Read the article

  • Launching browser within CherryPy

    - by Alan Harris-Reid
    I have a html page displayed using... cherrypy.quickstart(ShowHTML(htmlfile), config=configfile) Once the page is loaded (eg. initiated via. the command 'python mypage.py'), I would like to automatically launch the browser to display the page (eg. via. http://localhost/8000). Is there any way I can achieve this (eg. via. a hook within CherryPy), or do I have to call-up the browser manually (eg. by double-clicking an icon)? TIA Alan

    Read the article

  • How to find date ranges in records with consecutive dates and duplicate data

    - by alan s
    There's probably any easy solution for this, but I can't see it. I have a table with consecutive dates and often duplicate associated data for several of these consecutive dates: Date Col1 Col2 5/13/2010 1 A 5/14/2010 1 A 5/15/2010 2 B 5/16/2010 1 A 5/17/2010 1 A 5/18/2010 3 C 5/19/2010 3 C 5/20/2010 3 C Using MS T-SQL, I wish to find the start and end dates for each run of distinct Col1 and Col2 values: StartDate EndDate Col1 Col2 5/13/2010 5/14/2010 1 A 5/15/2010 5/15/2010 2 B 5/16/2010 5/17/2010 1 A 5/18/2010 5/20/2010 3 C Assumptions: There are never any missing dates. Col1 and Col2 are not null. Any ideas - preferably that don't use cursors? Many thanks, -alan

    Read the article

  • jQuery: How to find elements *without* a class set

    - by Alan
    Hey jQuery clever peeps, Why does this fail... $( 'div.contactAperson input' ).not( 'input.hadFocus' ).focus(function() { $(this).attr('value', '' ); }); ...it's meant to sniff out input's that have not got the class .hadFocus and then when one of that subset receives focus it should zap the value to null. Right now, input values are always getting zapped -- the test .not( 'input.hadFocus' ) is failing to stop execution. Btw, preceding the above code is the following code, which is working fine: $( 'div.contactAperson input' ).focus(function() { $( this ).addClass( 'hadFocus' ); }); Thanks for any cleverness - cheers, -Alan

    Read the article

  • Why does my Intel HDA onboard sound card not have a "Mix" device / channel?

    - by Hanno Fietz
    I want to be able to record what my sound card outputs on the speakers / headphones. This question is all over the interwebs again and again, and there seem to be two outcomes: in your selection of audio input devices, there's a device called "Stereo Mix", or similar, which is the "loopback" device for audio. Choose that in your recording tool and you're done. there's no such device and only speculative posts about why that may be. Now, I'm using ALSA and an Intel HDA chipset on my mainboard under Kubuntu Karmic. I have some 5-10 output channels and "Mic", "Front Mic" and "Line" for input. All of those are available in KMix, Audacity and other software. No "loopback" / "Mix" / whatever. Do I have to get some driver / kernel module set up ALSA in some way set up my system configuration in some way use a software solution (such as JACK) I had a look at JACK, and found it rather hard to understand, it's either an expert tool or just clumsy, I couldn't say. At least, I wasn't able to figure out how to achieve what I wanted. One of my problems seems to be that I don't understand where and how the mixing happens. Are there sound cards which just aren't able to do it? Why does the sound card matter at all, since I could in theory grab the data stream at some point before it goes to the hardware, right?

    Read the article

  • I want to set up a DynDNS service, what do I need to know?

    - by Hanno Fietz
    I'm gathering data from field devices, some of which will soon be behind a cellular-to-Ethernet gateway. Some of the devices need to be polled, and since the cellular carrier will usually assign changing IPs, I'm getting a gateway which has a Dynamic DNS client built in. I would like to have the devices call my own servers instead of a public DynDNS provider. What do I need to know to get started?

    Read the article

  • How do I find funny pictures?

    - by Hanno Fietz
    No, not lolcats. And I'm not really looking for a specific site, either. I have often wished that I had some funny picture to illustrate a presentation, a website, a post, an email, or something else. Google image search and stock photo services have hardly ever helped me, although that may be because I'm doing something wrong. Jeff Atwood seems to have no problem to find funny pictures for his codinghorror and stackoverflow blogs, as well as for the error messages on the trilogy sites. One of my favourites was this elephant. Other bloggers also seem to be quite good at it. I'm wondering if I simply lack the creativity or if there's sources or methods I don't know about. I could think of the following ways to get pictures, but I'm not sure whether this is really "how they do it". keep a collection of pictures that you stumbled upon and liked (takes quite some time to build up to a proper library), when you need a picture, there's one in there maybe have pictures on paper, too, like from magazines or ads. when you are looking for a picture, search online (Flickr, Google, stock photos). This has never really worked for me, I don't know why. produce the pictures yourself, i. e. have a good library of source material or find some online and apply some creativity and suitable software. I could imagine that this could work well once you have the practice.

    Read the article

  • How does Amarok rip Audio CDs (in Ubuntu Lucid)?

    - by Hanno Fietz
    I'm in the process of moving my CD collection into my Amarok library. Mostly, it works great. Sometimes however, the process just hangs forever. The problem seems to occur at random (i. e. often, but not always at the same disk/track) and the consequences range from none (successful after cancel/retry) to Amarok's internal db becoming completely messed up. I would like to investigate and file a proper bug report or find a fix / workaround, but I don't understand how Amarok does the ripping. When all is working, there's a lame process encoding to a temporary file, which appears in my collection once it's finished. When the process hangs, that lame command is still there, but waiting forever for data on stdin, which seems to come from a third process. That seems to be kio_audiocd, but I don't know whether that's correct and what it's supposed to do. What's going on?

    Read the article

  • There's no sound on Ubuntu with an Intel HDA onboard chip and Realtek ALC1200 codec.

    - by Hanno Fietz
    For a while now, my sound has not been working in Ubuntu. It used to play OK, but after some upgrade (might have been distro upgrade to 9.10), it stopped working. I'm currently running 10.04 on an amd64 architecture. I'm using the builtin audio on a Foxconn motherboard, it's an ATI / Intel HDA chip with an Azalia controller, apparently it's using the Realtek ALC1200 codec. All the gory details here. I found a nice sound troubleshooting tutorial here, which is well-written and pretty extensive, however, I fail to look up the supported "models" for my soundcard. The troubleshooting page says to look for a section giving the codec used by your soundcard, which looks like this for me: !!HDA-Intel Codec information !!--------------------------- --startcollapse-- Codec: Realtek ALC1200 Then, I'm supposed to lookup the models for that codec in the file Documentation/ALSA-Configuration.txt in the appropriate directory of ALSA's git repository. Mine actually pointed me to a separate file, Documentation/HD-Audio-Models.txt, which, for my driver version is located here and contains no section related to ALC1200 codecs. I tried putting the driver options probe-mask=1 and model=auto in a config file for modprobe, as suggested elsewhere, but this just lead to snd-hda-intel not able to load at all anymore. I also tried installing the linux-backports-modules-alsa package for my kernel, because the description sounded promising, but that didn't change anything, either.

    Read the article

  • How can I install a headless JDK on an Ubuntu Jaunty server?

    - by Hanno Fietz
    I recently set up a build server that requires a JDK to run (for example, to compile the Java sources). The OpenJDK package in Ubuntu pulls in the OpenJDK JRE as a dependency which, in turn, depends on a large number of packages that are only relevant for graphical environments. For the standard JRE, there's a headless version of the package, but for the JDK, no. This issue has been discussed in various places before, and one solution that I found and used was this: $ apt-get --no-install-recommends -d install openjdk-6-jdk $ dpkg -i --ignore-depends=openjdk-6-jre /path/to/just-downloaded.deb While this worked, it now leaves my system with a broken dependency tree and apt-get refuses further installs untill I run apt-get -f. Is there a better solution to this?

    Read the article

  • How can I create an encrypted, bootable thumbdrive containing Linux?

    - by Hanno Fietz
    I want to have a bootable flash drive that's fully encrypted. I have not tested, but seem to like, TrueCrypt, which provides a fully encrypted system and has lots of other features I like (for instance, hidden volumes). Unfortunately, it seems, system encryption is only supported for Windows, although I'm not sure why. The crux here, I guess, is that you need a boot loader that is capable of asking for your password and decrypt the disk, at least the part that contains kernel and initrd. An alternative might be to have an unencrypted boot partition containing a more powerful system which will decrypt and mount the main partition. However, this brings up the question of whether you're introducing data leaks. Depending on the specific scenario, I may lack the experience to assess if this is a problem. So I'd strongly prefer a fully encrypted disk or a similarly straightforward alternative.

    Read the article

  • How do ALSA and PulseAudio relate?

    - by Hanno Fietz
    While trying to get my sound to work, I was wondering about the roles of ALSA and PulseAudio. I have both installed and was wondering, for example, which of them needs to know about my sound card. Both seem to be able to use each other, there's a pulseaudio plugin for ALSA, and on my system, alsa shows up as a sound card in pulseaudio. Which of the two does what, are they alternatives or complementary?

    Read the article

  • How do I troubleshoot an IPsec tunnel (from a cellular router to a public server)?

    - by Hanno Fietz
    I'm new to IPsec and struggling with a setup that might soon be widely used in our operations (provided I do understand it, eventually...). A cellular router (blackbox by netModule, from its log messages it seems to be running Linux and OpenSwan) connects a sensor network on customers' sites with our public server. We need to be able to connect into the local network, so I had the cell provider give me a public IP (a dynamic one). The way their setup works, the public IPs only allow IPsec traffic. I set up OpenSwan on our Ubuntu server (running Jaunty). This is my connection config from /etc/ipsec.conf: conn gprs-field-devices left=my.pub.lic.ip [email protected] #leftsubnet=192.168.1.129/25 right=%any [email protected] #rightsubnet=192.168.1.1/25 #rightnexthop=%defaultroute auto=add On the router, all I have is the Web UI, in which I made the following settings: "Remote endpoint": public IP of server, same as "left" above "Local Network Address": 192.168.1.1 "Local Network Mask": 255.255.255.128 "Remote Network Address": 192.168.1.129 "Remote Network Mask": 255.255.255.128 The pluto process on the server is listening for connections on port 500. It can't open a tunnel, obviously, because it doesn't know at which IP the client is. I set up a passphrase as PSK for @field.econemon.com in /etc/ipsec.secrets and also configured it in the router (which doesn't seem to support certificates). My problem is, nothing happens. The router just says, IPsec is "down". When I copy-paste the IP into ipsec.conf (for "right="), and ask the server to ipsec auto --up gprs-field-devices, it just hangs until I press Ctrl-C. Is there anything wrong with my setup? How can I debug this further? My router gives the following loglines that seem related, but don't tell me anything: Feb 21 23:08:20 Netbox authpriv.warn pluto[2497]: loading secrets from "/etc/ipsec.secrets" Feb 21 23:08:20 Netbox authpriv.warn pluto[2497]: loading secrets from "/etc/ipsec.d/hostkey.secrets" Feb 21 23:08:20 Netbox authpriv.warn pluto[2497]: loading secrets from "/etc/ipsec.d/netbox0.secrets" Feb 21 23:08:20 Netbox authpriv.warn pluto[2497]: "netbox00" #1: initiating Main Mode Feb 21 23:08:20 Netbox daemon.err ipsec__plutorun: 104 "netbox00" #1: STATE_MAIN_I1: initiate Feb 21 23:08:20 Netbox daemon.err ipsec__plutorun: ...could not start conn "netbox00" Feb 21 23:08:22 Netbox authpriv.warn pluto[2497]: packet from 188.40.57.4:500: ignoring informational payload, type NO_PROPOSAL_CHOSEN Feb 21 23:08:22 Netbox authpriv.warn pluto[2497]: packet from 188.40.57.4:500: received and ignored informational message Feb 21 23:08:28 Netbox user.warn parrot.system_controller[762]: IPSECCTRLR: Tunnel 0 is down for 0 seconds Feb 21 23:08:40 Netbox user.warn parrot.system_controller[762]: IPSECCTRLR: Tunnel 0 is down for 10 seconds Feb 21 23:08:52 Netbox authpriv.warn pluto[2497]: packet from 188.40.57.4:500: ignoring informational payload, type NO_PROPOSAL_CHOSEN

    Read the article

  • Why does my Intel Tolapai network chip not transmit packets?

    - by Hanno Fietz
    I'm trying to deploy an embedded system (NISE 110 by Nexcom) based on the Intel EP80579 (Tolapai) chip. Tolapai apparently integrates controllers for Ethernet etc. on a single chip (Intel homepage). The machine can't get a network connection. Diagnosis as far as I could manage: Drivers drivers from Intel compiled and installed without problems (version 1.0.3-144). Kernel version and Linux distribution (CentOS 5.2, 2.6.18) match the driver's installation instructions. drivers are loaded and show up in lsmod (module names are gcu and iegbe) interfaces eth0 and eth1 show up in ifconfig ifconfig I can bring up the interfaces with fixed IP pinging the interface locally works ifconfig shows flag UP but not RUNNING Link ethtool shows "Link detected: no", "Speed: unknown (65536)" and "Duplex: unknown (255)" Link LED is on on the other side of the cable, ethtool shows "Link detected: yes" and reports a speed of 1000 Mbps, which has allegedly been auto-neogotiated with the problematic device. Network traffic analysis the device does not reply on ARP, ICMP echo or anything else (iptables is down) when trying to send ICMP or DHCP requests, they never reach the other end activity LED is off on the device, on at the other end. I tried the following without any effect: Different cables (2 straight, one crossed), I get the link LED lit up on each. Three different devices on the other end (one PC, one netbook, one router) Fixed ARP table entries on both sides Connecting both network ports of the machine with each other, won't ping through the cable, but will ping locally. Tried straight and crossed cables for that.

    Read the article

  • How do I make a USB stick from which to install different OS's?

    - by Hanno Fietz
    Recently, I have made a number of USB sticks to install OS's (several Linux flavors, BSD, Windows) from, on machines that didn't have CD drives. Now, I would prefer to not overwrite the install USB sticks all the time, since it's handy to have them, but neither do I want to pile up USB sticks that I only need every 6 months. It would be great to have a bootable USB stick that fires up some minimal system, lets you choose an ISO image and then reboots from there. How would I go about this? Do I use some minimal Linux? Is there some kind of modified / specialized boot loader? Can I set up GRUB to do this? Should I use virtualization?

    Read the article

  • On Windows machines, what is the typical toolchain for remote maintenance?

    - by Hanno Fietz
    I need to deploy PHP and Python code and the appropriate environment (web server, db server) to remote Windows systems, and I don't know what toolchain would be the equivalent to ssh, scp, bash and the like. So, basically, what I need to be able to do is the following: access remote Windows with the appropriate privileges in a secure manner, like I routinely do with ssh (I don't even know whether that would be a text or graphic interface on Windows). remotely install software: Apache or IIS, MySQL or Postgres, Python or PHP copy files from remote (the application we're deploying) remotely configure the machine to run regular tasks (e. g. checking for updates to the application) automate tasks like downloading files from a designated place The main question is probably how I get onto the machine securely in the first place, and then the rest is general Windows admin knowledge, which probably is too broad a scope to fit into one question. I have years of experience with maintaining Linux boxes and I have used tools of varying sophistication on those, ranging from plain scping of PHP files to deployment of Java application containers and even full VMs with Vagrant. On Windows, I'm a complete noob, and I don't even know where to start. I have installed Apache, MySQL , PHP on a desktop machine maybe twice in my life, that's about it. Bonus points for things that work from a Linux machine at my end, but I could run a VM and do everything from there.

    Read the article

  • How do I make a USB stick from which to install different OS's?

    - by Hanno Fietz
    Recently, I have made a number of USB sticks to install OS's (several Linux flavors, BSD, Windows) from, on machines that didn't have CD drives. Now, I would prefer to not overwrite the install USB sticks all the time, since it's handy to have them, but neither do I want to pile up USB sticks that I only need every 6 months. It would be great to have a bootable USB stick that fires up some minimal system, lets you choose an ISO image and then reboots from there. How would I go about this? Do I use some minimal Linux? Is there some kind of modified / specialized boot loader? Can I set up GRUB to do this? Should I use virtualization?

    Read the article

  • Transactional Messaging in the Windows Azure Service Bus

    - by Alan Smith
    Introduction I’m currently working on broadening the content in the Windows Azure Service Bus Developer Guide. One of the features I have been looking at over the past week is the support for transactional messaging. When using the direct programming model and the WCF interface some, but not all, messaging operations can participate in transactions. This allows developers to improve the reliability of messaging systems. There are some limitations in the transactional model, transactions can only include one top level messaging entity (such as a queue or topic, subscriptions are no top level entities), and transactions cannot include other systems, such as databases. As the transaction model is currently not well documented I have had to figure out how things work through experimentation, with some help from the development team to confirm any questions I had. Hopefully I’ve got the content mostly correct, I will update the content in the e-book if I find any errors or improvements that can be made (any feedback would be very welcome). I’ve not had a chance to look into the code for transactions and asynchronous operations, maybe that would make a nice challenge lab for my Windows Azure Service Bus course. Transactional Messaging Messaging entities in the Windows Azure Service Bus provide support for participation in transactions. This allows developers to perform several messaging operations within a transactional scope, and ensure that all the actions are committed or, if there is a failure, none of the actions are committed. There are a number of scenarios where the use of transactions can increase the reliability of messaging systems. Using TransactionScope In .NET the TransactionScope class can be used to perform a series of actions in a transaction. The using declaration is typically used de define the scope of the transaction. Any transactional operations that are contained within the scope can be committed by calling the Complete method. If the Complete method is not called, any transactional methods in the scope will not commit.   // Create a transactional scope. using (TransactionScope scope = new TransactionScope()) {     // Do something.       // Do something else.       // Commit the transaction.     scope.Complete(); }     In order for methods to participate in the transaction, they must provide support for transactional operations. Database and message queue operations typically provide support for transactions. Transactions in Brokered Messaging Transaction support in Service Bus Brokered Messaging allows message operations to be performed within a transactional scope; however there are some limitations around what operations can be performed within the transaction. In the current release, only one top level messaging entity, such as a queue or topic can participate in a transaction, and the transaction cannot include any other transaction resource managers, making transactions spanning a messaging entity and a database not possible. When sending messages, the send operations can participate in a transaction allowing multiple messages to be sent within a transactional scope. This allows for “all or nothing” delivery of a series of messages to a single queue or topic. When receiving messages, messages that are received in the peek-lock receive mode can be completed, deadlettered or deferred within a transactional scope. In the current release the Abandon method will not participate in a transaction. The same restrictions of only one top level messaging entity applies here, so the Complete method can be called transitionally on messages received from the same queue, or messages received from one or more subscriptions in the same topic. Sending Multiple Messages in a Transaction A transactional scope can be used to send multiple messages to a queue or topic. This will ensure that all the messages will be enqueued or, if the transaction fails to commit, no messages will be enqueued.     An example of the code used to send 10 messages to a queue as a single transaction from a console application is shown below.   QueueClient queueClient = messagingFactory.CreateQueueClient(Queue1);   Console.Write("Sending");   // Create a transaction scope. using (TransactionScope scope = new TransactionScope()) {     for (int i = 0; i < 10; i++)     {         // Send a message         BrokeredMessage msg = new BrokeredMessage("Message: " + i);         queueClient.Send(msg);         Console.Write(".");     }     Console.WriteLine("Done!");     Console.WriteLine();       // Should we commit the transaction?     Console.WriteLine("Commit send 10 messages? (yes or no)");     string reply = Console.ReadLine();     if (reply.ToLower().Equals("yes"))     {         // Commit the transaction.         scope.Complete();     } } Console.WriteLine(); messagingFactory.Close();     The transaction scope is used to wrap the sending of 10 messages. Once the messages have been sent the user has the option to either commit the transaction or abandon the transaction. If the user enters “yes”, the Complete method is called on the scope, which will commit the transaction and result in the messages being enqueued. If the user enters anything other than “yes”, the transaction will not commit, and the messages will not be enqueued. Receiving Multiple Messages in a Transaction The receiving of multiple messages is another scenario where the use of transactions can improve reliability. When receiving a group of messages that are related together, maybe in the same message session, it is possible to receive the messages in the peek-lock receive mode, and then complete, defer, or deadletter the messages in one transaction. (In the current version of Service Bus, abandon is not transactional.)   The following code shows how this can be achieved. using (TransactionScope scope = new TransactionScope()) {       while (true)     {         // Receive a message.         BrokeredMessage msg = q1Client.Receive(TimeSpan.FromSeconds(1));         if (msg != null)         {             // Wrote message body and complete message.             string text = msg.GetBody<string>();             Console.WriteLine("Received: " + text);             msg.Complete();         }         else         {             break;         }     }     Console.WriteLine();       // Should we commit?     Console.WriteLine("Commit receive? (yes or no)");     string reply = Console.ReadLine();     if (reply.ToLower().Equals("yes"))     {         // Commit the transaction.         scope.Complete();     }     Console.WriteLine(); }     Note that if there are a large number of messages to be received, there will be a chance that the transaction may time out before it can be committed. It is possible to specify a longer timeout when the transaction is created, but It may be better to receive and commit smaller amounts of messages within the transaction. It is also possible to complete, defer, or deadletter messages received from more than one subscription, as long as all the subscriptions are contained in the same topic. As subscriptions are not top level messaging entities this scenarios will work. The following code shows how this can be achieved. try {     using (TransactionScope scope = new TransactionScope())     {         // Receive one message from each subscription.         BrokeredMessage msg1 = subscriptionClient1.Receive();         BrokeredMessage msg2 = subscriptionClient2.Receive();           // Complete the message receives.         msg1.Complete();         msg2.Complete();           Console.WriteLine("Msg1: " + msg1.GetBody<string>());         Console.WriteLine("Msg2: " + msg2.GetBody<string>());           // Commit the transaction.         scope.Complete();     } } catch (Exception ex) {     Console.WriteLine(ex.Message); }     Unsupported Scenarios The restriction of only one top level messaging entity being able to participate in a transaction makes some useful scenarios unsupported. As the Windows Azure Service Bus is under continuous development and new releases are expected to be frequent it is possible that this restriction may not be present in future releases. The first is the scenario where messages are to be routed to two different systems. The following code attempts to do this.   try {     // Create a transaction scope.     using (TransactionScope scope = new TransactionScope())     {         BrokeredMessage msg1 = new BrokeredMessage("Message1");         BrokeredMessage msg2 = new BrokeredMessage("Message2");           // Send a message to Queue1         Console.WriteLine("Sending Message1");         queue1Client.Send(msg1);           // Send a message to Queue2         Console.WriteLine("Sending Message2");         queue2Client.Send(msg2);           // Commit the transaction.         Console.WriteLine("Committing transaction...");         scope.Complete();     } } catch (Exception ex) {     Console.WriteLine(ex.Message); }     The results of running the code are shown below. When attempting to send a message to the second queue the following exception is thrown: No active Transaction was found for ID '35ad2495-ee8a-4956-bbad-eb4fedf4a96e:1'. The Transaction may have timed out or attempted to span multiple top-level entities such as Queue or Topic. The server Transaction timeout is: 00:01:00..TrackingId:947b8c4b-7754-4044-b91b-4a959c3f9192_3_3,TimeStamp:3/29/2012 7:47:32 AM.   Another scenario where transactional support could be useful is when forwarding messages from one queue to another queue. This would also involve more than one top level messaging entity, and is therefore not supported.   Another scenario that developers may wish to implement is performing transactions across messaging entities and other transactional systems, such as an on-premise database. In the current release this is not supported.   Workarounds for Unsupported Scenarios There are some techniques that developers can use to work around the one top level entity limitation of transactions. When sending two messages to two systems, topics and subscriptions can be used. If the same message is to be sent to two destinations then the subscriptions would have the default subscriptions, and the client would only send one message. If two different messages are to be sent, then filters on the subscriptions can route the messages to the appropriate destination. The client can then send the two messages to the topic in the same transaction.   In scenarios where a message needs to be received and then forwarded to another system within the same transaction topics and subscriptions can also be used. A message can be received from a subscription, and then sent to a topic within the same transaction. As a topic is a top level messaging entity, and a subscription is not, this scenario will work.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >