Whenever some of the unconfigured MIME types are sent for publishing our publisher is hanging up and someone has to manually kill the process to get it running.
To get rid of this, I am trying to understand DD4T and want to know how to fix this. Currently we are using ECL library for resolving multimedia items from an external asset management system. We either need to fail publishing or publishing should succeed rather than hanging up the publisher.
Update:
Below is the code I have updated. I have hard coded variant ID for the time being. Still the publisher is hanging up. Am i missing something?
protected virtual void PublishItem(Item item, TcmUri itemUri, out int ImageWidth, out int ImageHeight)
{
ImageWidth = 0;
ImageHeight = 0;
Stream itemStream = null;
// See if some template set itself as the applied template on this item
TcmUri appliedTemplateUri = null;
if (item.Properties.ContainsKey(Item.ItemPropertyTemplateUri))
{
appliedTemplateUri = new TcmUri(item.Properties[Item.ItemPropertyTemplateUri]);
}
try
{
string publishedPath;
if (targetStructureGroupUri == null)
{
log.Debug("no structure group defined, publishing binary with default settings");
Component mmComp = (Component)engine.GetObject(item.Properties[Item.ItemPropertyTcmUri]);
// Note: it is dangerous to specify the CT URI as variant ID without a structure group, because it will fail if you publish the same MMC from two or more CTs!
// So I removed the variant ID altogether (QS, 20-10-2011)
log.Debug(string.Format("publishing mm component {0} without variant id", mmComp.Id));
//Binary binary = engine.PublishingContext.RenderedItem.AddBinary(mmComp);
string fileName = ConstructFileName(mmComp, currentTemplate.Id);
using (Stream stream = CreateTemperaryFileStream())
{
item.GetAsStream().CopyTo(stream);
Binary binary = engine.PublishingContext.RenderedItem.AddBinary(stream, fileName, "1024X1024", mmComp, mmComp.BinaryContent.MultimediaType.MimeType);
publishedPath = binary.Url;
}
log.Debug(string.Format("binary is published to url {0}", publishedPath));
}
else
{
Component mmComp = (Component)engine.GetObject(item.Properties[Item.ItemPropertyTcmUri]);
string fileName = ConstructFileName(mmComp, currentTemplate.Id);
StructureGroup targetSG = (StructureGroup)engine.GetObject(targetStructureGroupUri);
itemStream = item.GetAsStream();
if (itemStream == null)
{
// All items can be converted to a stream?
log.Error(String.Format("Cannot get item '{0}' as stream", itemUri.ToString()));
}
//byte[] data = new byte[itemStream.Length];
//itemStream.Read(data, 0, data.Length);
//itemStream.Close();
log.Debug(string.Format("publishing mm component {0} to structure group {1} with variant id {2} and filename {3}", mmComp.Id, targetStructureGroupUri.ToString(), currentTemplate.Id, fileName));
//Binary b = engine.PublishingContext.RenderedItem.AddBinary(item.GetAsStream(), fileName, targetSG, currentTemplate.Id, mmComp, mmComp.BinaryContent.MultimediaType.MimeType);
//publishedPath = engine.AddBinary(itemUri, appliedTemplateUri, targetStructureGroupUri, data, fileName);
using (Stream stream = CreateTemperaryFileStream())
{
itemStream.CopyTo(stream);
Binary b = engine.PublishingContext.RenderedItem.AddBinary(stream, fileName, targetSG,
currentTemplate.Id, mmComp,
mmComp.BinaryContent
.MultimediaType
.MimeType);
publishedPath = b.Url;
}
log.Debug(string.Format("binary is published to url {0}", publishedPath));
}
log.Debug("binary published, published path = " + publishedPath);
item.Properties[Item.ItemPropertyPublishedPath] = publishedPath;
}
finally
{
if (itemStream != null) itemStream.Close();
}
}
AddBinary()
method, or are they just resolved to a direct link or template fragment?IContentLibraryMultimediaItem.GetContent()
, could it be that the content stream is just incredibly large and the Publisher isn't really hanging but getting a lot of data? Last week my Resolve ECL Items TBB was changed to save the stream to a file temporarily for performance reasons, see theCreateTemporaryFileStream()
method.