Nservicebus Message stuck and not being processed or Handle - message-queue

We have two ASP.net web applications integrated with nservicebus with following configuration
App 1 is running nuservicebus v4 and App 2 is running nservicebus v3.
When I send the message from app 1 to app 2 it works fine and get processed. While when I send the message from app 2 to app 1 message gets delivered to messaging queue but doesn't get processed until I restart the app 1 from IIS.
my app.configs are as followed.
App-1
<configSections>
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
<section name="TransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
<TransportConfig MaximumConcurrencyLevel="5" MaxRetries="2" MaximumMessageThroughputPerSecond="0"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Assembly="AssemblyName" Endpoint="EndPoint#MachineName"/>
</MessageEndpointMappings>
</UnicastBusConfig>
App-2
<configSections>
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
<MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="AssemblyName" Endpoint="EndPoint#machineName"/>
</MessageEndpointMappings>
</UnicastBusConfig>
Could you please advise? Thanks.

Related

Returning a custom response code for for serving static html when using IIS ApplicationInitialization remapManagedRequestsTo feature?

I'm currently using the ApplicationInitialization feature of IIS to warm up my ASP.NET application. I've set the attribute remapManagedRequestsTo to "warmup.html".
<applicationInitialization remapManagedRequestsTo="warmup.html" skipManagedModules="true" doAppInitAfterRestart="true" >
<add initializationPage="/home" />
<add initializationPage="/about-us" />
</applicationInitialization>
It's working well but I would like to return a custom status code when the content for Warmup.html is returned to the browser. This is so that when I run some smoke tests after deployment I get to know when the warm up has finished.
I've tried using URL Rewrite to change the status code from 200 to 555 to serve up warmup.html and it does change the status code but doesn't serve the content in warmup.html
<rewrite>
<rules>
<rule name="Change warm up status code" stopProcessing="true">
<match url="warmup.html" />
<action type="CustomResponse" statusCode="555" subStatusCode="0"/>
</rule>
</rules>
</rewrite>
Is there a way I can do both the serving of warmup.html's content AND return a custom status code of 555?
Finally found my answer in a blog post written by Morten Bock
Turns out I have to remove the two attributes remapManagedRequestsTo and skipManagedModules (default value of false) which leaves us with
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/home" />
<add initializationPage="/about-us" />
</applicationInitialization>
Then let the URL Rewrite module take over but we want to rewrite the response code when the Application Initialization is making the request marked by the server variable APP_WARMING_UP containing a value of 1. When this condition is met we can create a custom response as the action and pop the statusCode attribute with 555.
<rewrite>
<rules>
<rule name="WarmUp" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{APP_WARMING_UP}" pattern="1" />
</conditions>
<action type="CustomResponse" statusCode="555" statusReason="Site is warming up" statusDescription="Try again shortly" />
</rule>
</rules>
</rewrite>
Then to catch the status 555 as a custom error and direct the user to the friendly warm up page warmup.html
<system.webServer>
<httpErrors errorMode="Custom">
<error statusCode="555" path="warmup.html" responseMode="File" />
</httpErrors>
</system.webServer>

Android Wear companion activity gear does not show up in watch face

I wanted to provide a Companion Configuration Activity for my Android Wear watch face. I have already build the app that has all the configuration and can communicate directly with the watch face, but I can only launch it from the launcher as app, but the gear does not show up in the watch face section of Android Wear app! Can I allow user to configure the watch face via companion app and also via Google Android Wear app?
This is how I declare my activity in phone module:
<activity
android:name=".Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<data android:mimeType="image/*"></data>
</intent-filter>
</activity>
On the watch part, I added in:
<meta-data
android:name=
"com.google.android.wearable.watchface.companionConfigurationAction"
android:value=
"virtualgs.photowatch.Main" />
<meta-data
android:name=
"com.google.android.wearable.watchface.wearableConfigurationAction"
android:value=
"virtualgs.photowatch.Main" />
And the result is the same - no gear shown on the Android Wear app.
Try something like this:
Phone Manifest:
<intent-filter>
<action android:name="com.virtualgs.photowatch.MAIN_CONFIG" />
<category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Watch Manifest:
<meta-data
android:name="com.google.android.wearable.watchface.companionConfigurationAction"
android:value="com.virtualgs.photowatch.MAIN_CONFIG" />
I think the intent action in the phone manifest has to be the same as the meta-data value in the watch manifest to work.
I think this is the correct answer about XML file config:
<activity
android:name=".DigitalWatchFaceWearableConfigActivity"
android:label="#string/digital_config_name">
<intent-filter>
<action android:name=
"com.example.android.wearable.watchface.CONFIG_DIGITAL" />
<category android:name=
"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
As well as having the activity defined in the phone module, you need to reference it in the wear module as part of the declaration of your watch face service like this:
<service
android:name=".MyWatchFaceService" ... />
<!-- companion configuration activity -->
<meta-data
android:name=
"com.google.android.wearable.watchface.companionConfigurationAction"
android:value=
"com.my.watchface.CompanionConfigurationActivity" />
<!-- wearable configuration activity -->
<meta-data
android:name=
"com.google.android.wearable.watchface.wearableConfigurationAction"
android:value=
"com.my.watchface.WearableConfigurationActivity" />
...
Replacing com.my.watchface.CompanionConfigurationActivity and com.my.watchface.WearableConfigurationActivity with the fully qualified names of the configuration activities in the wear and phone modules respectively.

Read web.config settings in html page without extension

I need to read web.config settings. I have added following settings to web.config
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="PageHandlerFactory-Integrated-HTML" path="*.html"
verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory"
resourceType="Unspecified" preCondition="integratedMode,runtimeVersionv4.0" />
and
<buildProviders>
<add extension=".html"
type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
It works fine for all html pages that have.html in extension.
But for pages urls like http://testsite.com/aaa which displays 404 html page in response , the configuration is not read.
What can be done to include pages without extensions.
I was facing this issue for error pages.
After changing settings for httpErrors in web.config, things worked for me.
I changed
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="holdingClientError.html" responseMode="File" />
To
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/holdingClientError.html" responseMode="ExecuteURL" />

ServiceStack 4 Razor: no intellisense in Visual Studio 2013 with update 2

I am running a Asp.Net Host (ServiceStack.Host.AspNet 4.0.30.0) - ServiceStack 4.0.30.0 project with Razor.
.Net Framework Target: 4.5.1
The project compiles fine, but I am not getting any intellisense in my Razor Views using Visual Studio 2013 with Update 2.
Any ideas on how to get intellisense to work in the ServiceStack Razor views?
My machine has MVC 4 and 5 installed as well.
Here is also a copy of my web.config...
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.1" />
</system.Web>
-->
<system.web>
<httpRuntime />
<compilation targetFramework="4.5.1" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders></compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers></system.web>
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="windows_consumer81_demo.Models" />
<add namespace="windows_consumer81_demo.Models.Scenario" />
<add namespace="windows_consumer81_demo.Localization" />
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="windows_consumer81_demo" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
</system.web.webPages.razor>
<appSettings>
<add key="DebugMode" value="true" />
<add key="unsupportedRedirect" value="unsupported.html" />
<add key="vs:EnableBrowserLink" value="false" />
<add key="webPages:Enabled" value="false" /></appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</configuration>
I guess the way it's supposed to work is that all the namespaces you add in web.config should have IntelliSense:
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="YourNameSpaceHere" />
<add namespace="SomeServiceStackNameSpace" />
. . .
Then in the .cshtml file you'd add:
#inherits ViewPage<YourModelClassName>
Unfortunately this doesn't always work. It compiles, but you don't get IntelliSense.
However there is a fix:
In your .cshtml file just type out the full namespace:
#inherits ServiceStack.Razor.ViewPage<Full.Namespace.Of.Your.Model.Class>
If you're using other classes, just add:
#using MyServer.ServiceInterface;
#using MyServer.ServiceModel;
Another trick I recommend is to strongly type your #Model object. Right there at the top, after the #Inherits ViewPage<...> stuff add:
#{
Your.Class.Name TypedModel = Model;
}
Feel free to rename TypedModel to something better.

How Can I Secure HTML Files that are Created Dynamically in My ASP.NET 4 Web App?

I am running an ASP.NET 4 application on a Windows 8 R2 server with IIS 7. The application dynamically creates HTML files in a sub-directory "Reports" within the app's root directory. I am attempting to secure these files using the already existing Forms Authentication by making the following changes to the web.config file:
Added these four lines to the <compilation> section:
<buildProviders><br />
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> <br />
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" /> <br />
</buildProviders> <br />
Added these four lines to the <system.web> section:
<httpHandlers><br />
<add verb="*" path="*.htm" type="System.Web.UI.PageHandlerFactory" /><br />
<add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory" /><br />
</httpHandlers><br />
Tried both of the following
"<handlers>" in the "<system.webServer>" section:<br />
<handlers><br />
<add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" /><br />
<add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" /><br />
</handlers><br />
and
<handlers><br />
<add name="HtmlHandler-Integrated" path="*.html" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" modules="ManagedPipelineHandler" /><br />
<add name="HtmHandler-Integrated" path="*.htm" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" requireAccess="Script" preCondition="integratedMode" modules="ManagedPipelineHandler" /><br />
</handlers><br /><br />
Finally, I added a <location> tag to specify the "role-based" security for the folder:
<br />
<location path="Reports"><br />
<system.web><br />
<authorization><br />
<allow roles="Administrator, Base User" /><br />
<deny users="*" /><br />
</authorization><br />
</system.web><br />
</location><br /><br />
These settings work fine for non-authenticated users, but produce the error "The file '....htm' has not been pre-compiled, and cannot be requested." for the HTML files that are dynamically created from the application.
What other changes are necessary to protect these "html" files from non-authenticated users?
Thanks!