Skip to content

Instantly share code, notes, and snippets.

View andreasohlund's full-sized avatar

Andreas Öhlund andreasohlund

View GitHub Profile
$ServiceName = "the service"
$service = Get-Service $ServiceName -ErrorAction SilentlyContinue
Start-Service $ServiceName
$service = Get-Service "the service" -ErrorAction SilentlyContinue
if ($service)
{
"Backend service is already installed, going to uninstall first"
#get the path to the current service
$servicePath = "HKLM:SYSTEM\CurrentControlSet\Services\$service"
$serviceKey = get-itemproperty -path $servicePath -ErrorAction silentlycontinue
$serviceName = "the name of the service"
$service = Get-Service $serviceName -ErrorAction SilentlyContinue
if ($service)
{
Stop-Service $ServiceName -Force
Start-Sleep -s 10
if($service.Status -ne 'stopped' ){
@andreasohlund
andreasohlund / nhuow.cs
Created August 8, 2013 08:54
NH bug workaround
void IManageUnitsOfWork.End(Exception ex)
{
if (SessionFactory == null || currentSession == null) return;
if (ex != null)
{
Transaction.Current.Rollback(ex);
while (Transaction.Current.TransactionInformation.Status != TransactionStatus.Aborted)
{
using RestSharp;
var client = new RestClient("http://localhost:8888/api");
var request = new RestRequest("endpoints", Method.GET);
var response = client.Execute<List<Endpoint>>(request);
foreach(var endpoint in response.Data)
{
Console.Out.WriteLine(endpoint.Name);
//define new convention
Configure.Conventions.RabbitMq(c => c.ExchangeNameForPubSub((a, t) => a.Queue));
//create the exchanges as needed
public class ExchangeInstaller:INeedToInstallSomething<Windows>
{
public IManageRabbitMqConnections ConnectionManager { get; set; }
public void Install(string identity)
{
@andreasohlund
andreasohlund / AddressRewriter.cs
Created November 17, 2012 17:56
Address rewriter for use of FQDS
using NServiceBus;
using NServiceBus.MessageMutator;
using NServiceBus.ObjectBuilder;
public class AddressRewriter:IMutateOutgoingTransportMessages,INeedInitialization
{
public void MutateOutgoing(object[] messages, TransportMessage transportMessage)
{
transportMessage.ReplyToAddress = LocalAddress;
}
@andreasohlund
andreasohlund / WrappingFaultManager.cs
Created November 17, 2012 17:11
Wrapping the existing nsb faults forwarder
using System;
using NServiceBus;
using NServiceBus.Faults;
namespace MyServerWithSLR
{
using NServiceBus.Faults.Forwarder;
public class MyOwnFaultManager : IManageMessageFailures, INeedInitialization
{
<connectionStrings>
<add name="NServiceBus.Persistence" connectionString="url=http://localhost.fiddler:8080"/>
</connectionStrings>
<system.net>
<defaultProxy>
<proxy usesystemdefault="False" bypassonlocal="True" proxyaddress="http://127.0.0.1:8888"/>
</defaultProxy>
</system.net>